jQuery quicksand plugin with .click method

核能气质少年 提交于 2019-12-03 22:06:51

问题


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.


回答1:


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).



来源:https://stackoverflow.com/questions/4840741/jquery-quicksand-plugin-with-click-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!