jquery - Detect when an element is done loading new HTML -
i have load event in js file, uses .on('load') load in new html when clicking on pagination. however, need happen in script once html done loaded. far i've tried this, no luck. js-ajax-content-container element loading in new html. js-ajax-link pagination link click initiate load event.
$('body').on('click', '.js-ajax-link', function() { $('body').on('.js-ajax-content-container', 'ajaxcomplete', function() { alert("loaded"); }); });
you can fire custom event in 1 script , listen in another.
by way, arguments in wrong order on()
.
first pass event name , selector.
$('body').on('click', '.js-ajax-link', function() { $('body').on('ajaxcomplete','.js-ajax-content-container', function() { $(document).trigger('ajaxlinkloaded'); }); });
and in script can listen event:
$(document).on('ajaxlinkloaded', function(e){ // something});
Comments
Post a Comment