After ajax is used, lazyload. js becomes invalid. How can this problem be solved?

Source: Internet
Author: User
Yes. My website mainly uses images, so I Reference lazyload. js and infinitescroll. js is good for user experience, infinitescroll. javascript uses ajax to automatically load the content of the next page when the page is rolled down. The problem is that the image of the next page loaded by ajax l... yes. My website mainly uses images, so I Reference lazyload. js and infinitescroll. js is good for user experience, infinitescroll. javascript uses ajax to automatically load the content of the next page when the page is rolled down.

The problem is that the lazyload. js image on the next page loaded by ajax is invalid, the image cannot be displayed, and some JavaScript files cannot work.

I have been using Baidu for a long time and want to bind events, such as sliding display or clicking display:

$('body').on('mouseover' , '.myDrop' ,        function() {          $(this).addClass('open');        }    );

This binding works, but the lazyload. js configuration is executed when the page is loaded. What should I do?
The following is the configuration of lazyload. js:

$(function() {    $("img.img-responsive").lazyload({      effect : "fadeIn",      threshold : 200    });  });
Reply content:

1. If you have to do so, initialize lazyload again during ajax callback.

2. You can re-execute your initialization code after each ajax operation, so that you can

$.ajax({   type: "POST",   url: "XXX",   data: "XXXX",   success: function(msg){     $("img.img-responsive").lazyload({      effect : "fadeIn",      threshold : 200    });   }});

After ajax is used, lazyload. js becomes invalid. How can this problem be solved? For more information, see the PHP Chinese website (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.