2012-06-13 128 views
1

可能重复:
Backbone.js View can't unbind events properly解除绑定事件

我与touchend因为swipe.js也为我指示的事件监听器名为项股利。现在div#商品里面有孩子问题是如果我正在听touchend div#商品难以点击或点击div#商品的商品。我试图解开它,但没有运气。我正在使用骨干,所以这是我的代码:

event: { 
    "touchend #item" : "CheckIndex" 
}, 

CheckIndex : function(e){ 
    e.stopPropagation(); 
    var _a = this.swipe.index+1; 
    $("#item).unbind('touchend'); 
}, 
+0

什么是你真正想在这里实现?我已经使用swipe.js刷卡项目有孩子可以挖掘?你能否说明你想要做什么,也许有另一种解决ypur问题的方法? – 2012-06-13 10:24:26

+0

其实我没有得到它的工作。该解决方案在swipe.js本身的回调函数内。谢谢。 – jongbanaag

回答

2

这是我如何解决它。

CheckIndex : function(e){ 
    e.stopPropagation(); 
    var _a = this.swipe.index+1; 
    this.$el.unbind('touchend'); //instead of $("#item").unbind('touchend'); 
}, 
0

这是一个错字吗?你错过了项目

结束的双引号
$("#item).unbind('touchend'); 

应该

$("#item").unbind('touchend');