As we all know, since jQuery 1.7:
$('someSelector').live('click', fn());
became essentially:
$(document).on('click', 'someSelector', fn());
All direct events are not directly attached to the elements in the selector, but are delegated to the document.
This, I believe, is that elements that will be matched 'someSelector'in the future are not present in the DOM, so you cannot bind event handlers (using direct or delegated bindings).
For single-page applications, where the vast majority, if not all elements are dynamically loaded, recommendations are published on how to best deal with the performance problem by linking everything to the document?
Coverage, for example, is the best way to register / re-register event handlers when new content is loaded through ajax()and how to update code written in lazy .live()thinking?
source
share