2015-12-05 121 views
1

我对Ajax调用增加新的项目,每一次我检查我点击是否同位素已经初始化,同位素布局发生全部铺设新的项目,但下面不会发生如何检查同位素是否已经初始化?

if($("#list").data('isotope')) { 
    alert("hello"); 
} 

反正是有检查同位素是否已经初始化?

回答

0

我让它工作的唯一方法是检查一个变量。

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 
} 
}); 

Ajax调用之前我设置一个VAR为false,那么当我打开我的项目我第一次检查,如果我的变量被设置为true,如果不是我把它设置为true和负载同位素。当我再次加载项目时,我的var将被设置为true,因为我第一次启动同位素时设置为true,因此我知道同位素已经启动。

相关问题