0
我想通过live()方法将函数与函数绑定。 该功能仅在第一次使用时表现良好。 我认为我必须从任何事件中解开这个元素并反弹相同的功能,但我不知道该怎么做!回弹相同功能
下面是代码:
var temp = function() {
var htmlEx = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
$('#template_loading').fadeIn();
$('#template_loading').queue(function() {
$('#tp_prev').html(htmlEx);
$('#template_container').removeClass("cur_temp");
$('#template_container').addClass("cur_prev");
$('#template_container').animate({"margin-left" : "0"}, 400, 'easeOutExpo');
$('#template_container').queue(function() {
$('#template_loading').fadeOut();
$('#tp_cur').empty();
$('#template_container').removeClass("cur_prev");
$('#template_container').addClass("cur_temp");
$('#tp_prev').empty();
$('#tp_cur').html(htmlEx);
$('#tp_cur').queue(function() {
$('#prev.pers_arrow').die();
$('#prev.pers_arrow').live("click", temp);
$(this).dequeue();
});
$(this).dequeue();
});
$(this).dequeue();
});
};
$('#prev.pers_arrow').live("click", temp);
**该代码没有按”没有道理!**你删除了事件,然后再次添加它,并且函数的回调函数将自身添加为回调函数。 ** ha?!?!** – gdoron 2012-03-11 11:45:49
不,您通常不必删除并添加事件侦听器来多次运行它们。你可能对函数本身有问题。如果您详细说明实际问题,您想要实现什么,并解释代码应该做什么以及它做了什么,我们可以帮助您更好地实现。包括http://jsfiddle.net/演示会更好。 – 2012-03-11 11:47:20