如何检查同位素是否已初始化?
How to check if isotope has been initialised?
我在 ajax 调用中添加新项目,每次单击时我都会检查 isotope 是否已初始化,同位素布局会放置所有新项目,但不会发生以下情况
if($("#list").data('isotope')) {
alert("hello");
}
有没有办法检查同位素是否已经初始化?
我让它工作的唯一方法是检查一个变量。
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,然后当我加载我的项目时,我首先检查我的 var 是否设置为 true,如果不是,我将其设置为 true 并加载同位素。当我再次加载项目时,我的 var 将设置为 true,因为我在第一次启动同位素时设置了它,因此我知道同位素已启动。
我在 ajax 调用中添加新项目,每次单击时我都会检查 isotope 是否已初始化,同位素布局会放置所有新项目,但不会发生以下情况
if($("#list").data('isotope')) {
alert("hello");
}
有没有办法检查同位素是否已经初始化?
我让它工作的唯一方法是检查一个变量。
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,然后当我加载我的项目时,我首先检查我的 var 是否设置为 true,如果不是,我将其设置为 true 并加载同位素。当我再次加载项目时,我的 var 将设置为 true,因为我在第一次启动同位素时设置了它,因此我知道同位素已启动。