0

I use the lazyload plugin to load images on my website and it works great but when the images are loaded via AJAX (When you click on a thumbnail to load a post) the plugin doesn't seem to work on these images. Could it be that it's because the images were not initially in the DOM?

Any idea what I could do to solve this?

Many thanks.

Plugin: https://github.com/tuupola/jquery_lazyload

$("body img").lazyload({ 
    effect : "fadeIn",
    failure_limit : 99999,
    threshold : 100
});

1 Answer 1

3
testFunc = function(str, callback) {
    // Send our params
    var data = 'some data to send';
    $.ajax({
        type: 'POST',
        url: 'http://www.myurl.com',
        data: data,
        success: function(data) {

    $("body img").lazyload({ 
        effect : "fadeIn",
        failure_limit : 99999,
        threshold : 100
    });


        }
    });
}

Put the above function after success of ajax call..Since the image is not there event is not binding with those images.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.