Help to deal with the scope.
How can I see the ajaxDelete function from the second file?

backend.js (generic)

$(document).ready(function() { function ajaxDelete() { } }); 

pages.js

 $(document).ready(function() { $('.delete-entity').click(ajaxDelete); }); 

    1 answer 1

     <script src='jquery.js'></script> <script src='backend.js'></script> <script src='pages.js'></script> 

    pages.js

     $(document).ready(function() { $('.delete-entity').click(function() { ajaxDelete(); }); }); 

    backend.js (generic)

     $(document).ready(function() { ajaxDelete = function() { alert('qeqqe'); } }); 
    • yeah I almost tried it, but my trouble was that I wrote var ajaxDelete = ... - toxxxa
    • @toxxxa, oh, you're var lovers :) It is needed for a private variable in the current function - Mr. Black
    • Is there a way to somehow manually define the scope so as not to litter the global space? or usually do not bother, but simply give names to their functions that will not conflict with anything exactly? - toxxxa
    • @toxxxa, everyone writes in different ways, basically this is a shit code, in which people in a couple of weeks will not understand their code themselves. It is not necessary to prescribe var - everywhere . Black