0

I am fetching data from various resources through ajax and displaying them on page, jQuery.ready() . And applying isotope on $(window).load(function(){});.

Since writing from these number of resources takes time, it takes time to apply isotope masonry view. It is noticeable from HTML page. So for an alternate, I fetched 4-5 resources on jQuery.ready() => set isotope on $(window).load(function(){}); => then fetched data from rest resources on jQuery.load().

But any call in load() is not happening.

What should I do for this lazy loading, or rather lazy calling?

Amit Kumar Gupta
  • 7,193
  • 12
  • 64
  • 90

1 Answers1

0

$(window).load(function(){}) executes its callback when the window (and everything it contains, including images) has loaded. However, it does not take account of ajax requests that are made later. Therefore, I suspect your callback is firing (put in a console.log('callback called') line to check) but it is happening before JQuery has returned the results of your ajax requests and so does not work as you expect.

I've never used isotope, but I suspect the answer to your problem is to add some code to the success method in your ajax calls. This page of the isotope docs is probably what you need: http://isotope.metafizzy.co/docs/adding-items.html

Rob Johnstone
  • 1,704
  • 9
  • 14