-
Notifications
You must be signed in to change notification settings - Fork 233
Description
I have two different pages where I use jQuery.Lazy(). In the first page, AJAX is used to retrieve a record list via AJAX as soon as the page loads. Here .lazy works fine and the images fadein as soon as they show up in the viewport.
On the second page, the user can enter search criteria, and when they click the 'Search' button, a function is called that also uses AJAX to retrieve a record list with images ( see code below). Here though, the images do NOT fadein as soon as they are displayed. The placeholders are displayed, but the images don't fadein. You have to click/scroll the vertical scrollbar on the browser for the fadein to begin.
The ONLY difference that I can tell between the 2 pages is that the second one uses a function() to call the AJAX/retrieve, but the rest of the code is practically identical.
function mySearch() {
$('#myList').hide();
let pMyString = $('#myString').val();
$("#myList").load("mySearch/mySearchListPartial", { __RequestVerificationToken: '@token', "pMyString": pMyString, ... }, function (responseTxt, statusTxt, xhr) {
if (statusTxt == "success") {
let lazyInstance = $(".lazyLoadImage").Lazy({
chainable: false,
effect: "fadeIn",
effectTime: 1000,
threshold: 0
});
lazyInstance.update();
$('#myList').slideDown();
}
else if (statusTxt == "error") {
$('#myList').show().html('<p class="error-details">Error: ' + xhr.status + ': ' + xhr.statusText + '</p>');
}
});
}
How do I call .lazy to start the fadein of images that are initially displayed on the viewport as soon as they are loaded (without having to click/drag the vertical scrollbar first)?