ressio / lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media
http://ress.io/lazy-load-xt-jquery/
MIT License
1.36k stars 245 forks source link

Not working for the ajax loaded images/content... #71

Open ashishsahare opened 8 years ago

ashishsahare commented 8 years ago

Not working for the ajax loaded images/content...

goodwinpress commented 4 years ago

AJAX

If you use jQuery-based AJAX navigation and don't like to change existing AJAX callbacks, you can apply lazy loading to new loaded content using ajaxComplete event. Note that $.lazyLoadXT.loadEvent = 'pageshow ajaxComplete'; may not work correctly because of content is not added to the page at the time of ajaxComplete event, that's why it's better to postpone initialization by setTimeout:

/ JS / $(window).on('ajaxComplete', function() { setTimeout(function() { $(window).lazyLoadXT(); }, 50); });