how to add javascript code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hardware
    Junior Member
    • May 2023
    • 7

    how to add javascript code

    Good afternoon Tell me how to add code for export. So that the selected fields are successful. I do this, I edit the file /usr/share/nginx/html/client/res/templates/export/record, I wrote the code in it

    Code:
    <script>
    function del()
    {
    var inputElement = document.querySelector('input[data-name="fieldList"].selectized');
    var selectizeInstance = inputElement.selectize;
    selectizeInstance.clear();
    }
    <script>
    
    <button onclick="del()">Clean</button>
    Why is the code not running? The code works through the console​


    I want it to be possible to remove all selected fields when clicking, so as not to click on each cross with the mouse​. In short, how to add custom javascript to the system. Thanks for answers)
    Last edited by hardware; 12-07-2023, 11:41 AM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi,

    Client JS files and templates are bundled and minified. You modify sources that are not used in the app.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8440

      #3
      You can either build instance from sources (from the GitHub repository). But you will need to take care of upgrades by yourself, because upgrades will override your customization.

      You can also monkey patch: https://github.com/espocrm/espocrm/issues/2890. You can custom JS scripts can be added with https://docs.espocrm.com/development...nt/#scriptlist. Note that for developer mode there's a separate parameter.

      In your script you can require AMD module and perform monkey patching. But I would not recommend doing that as it's a not future-proof method.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • yuri
        Member
        • Mar 2014
        • 8440

        #4
        Code:
        require(['views/modals/export'], View => {
        
            const defaultSetup = View.prototype.setup;
        
            View.prototype.setup = function () {
                defaultSetup.call(this);
                
                // Custom code.
            };
        });​
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment


        • hardware
          hardware commented
          Editing a comment
          yuri, thanks for the answer
      Working...