具有.click方法的jQuery流沙插件 [英] jQuery quicksand plugin with .click method
问题描述
我试图将此.click函数添加到要使用jQuery的quicksand插件排序的每个图像中
I'm attempting to add this .click function to each image I'm sorting with the quicksand plugin for jQuery
$('li img').click(function() {
var verticalCenter = ($(window).height() - $('#popupContent').height() ) /2;
var horizontalCenter = ($(window).width() - $('#popupContent').width() ) /2;
$('#popupContent').css('top', verticalCenter);
$('#popupContent').css('left', horizontalCenter);
$('#backgroundPopup').fadeIn('slow');
$('#popupContent').fadeIn('slow');
});
它将正确创建弹出窗口,但排序后将停止工作. 该文档建议...
It will create the popup properly but after sorting it will stop working. The documentation suggests...
"当您的商品具有功能增强功能(例如工具提示)时,请记住使用回调将它们应用于新克隆的对象:
"When your items have functional enhancements (eg. tooltips), remember to use callback to apply them on newly cloned objects:
$("#content").quicksand($("#data > li"),
{
duration: 1000,
}, function() { // callback function
$('#content a').tooltip();
}
);
我不确定在哪里放置此代码并将其更改为适合我的情况的代码,请帮忙.
I'm not sure where to put this code and change it to work for my case, please help.
推荐答案
代替.click
使用 .live('click',function(){});
只要事件在整个DOM中被移动/克隆(只要您的选择器不变),它就会重新绑定到该事件.
Instead of .click
use .live('click',function(){});
This will re-bind to the event as they're being moved/cloned throughout the DOM (as long as your selector doesn't change).
这篇关于具有.click方法的jQuery流沙插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!