rob.m rob.m - 1 year ago 199
Javascript Question

How to check if isotope has been initialised?

I am adding new items on an ajax call, and I check each time I click if isotope has been initialised, the isotope layout happens laying all the new items but the following never happens

if($("#list").data('isotope')) {

Is there anyway to check if isotope has already been initialised?

Answer Source

The only way i made it working was by checking a variable.

var myVar = false;
jQuery.fn.almComplete = function(alm){ <-- my ajax callback
 if(myVar) { <-- my var is true, means isotope is initialised
      do something
 } else {
     myVar = true; <-- set my var tot rue as isotope is not initialised and
     start isotope

I am setting a var to false before the ajax call, then when I load my items I first check if my var is set to true and if not I set it to true and load isotope. When I will load items again my var will result as set to true as i set it when i started isotope the first time therefore i know isotope has initiliased.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download