Backbone.js 在jquery中取消绑定事件
可能重复:Backbone.js 在jquery中取消绑定事件,backbone.js,event-handling,jquery,Backbone.js,Event Handling,Jquery,可能重复: 我有一个名为div的项目,其中touchend有一个事件监听器,因为我的指示器也有swipe.js。现在div#Item中有子项,问题是如果我正在收听div#Item上的touchend,很难单击或轻触div#Item的子项。我试着解开它,但没有成功。我正在使用主干网,因此这是我的代码: event: { "touchend #item" : "CheckIndex" }, CheckIndex : function(e){ e.stopPropagation();
我有一个名为div的项目,其中touchend有一个事件监听器,因为我的指示器也有swipe.js。现在div#Item中有子项,问题是如果我正在收听div#Item上的touchend,很难单击或轻触div#Item的子项。我试着解开它,但没有成功。我正在使用主干网,因此这是我的代码:
event: {
"touchend #item" : "CheckIndex"
},
CheckIndex : function(e){
e.stopPropagation();
var _a = this.swipe.index+1;
$("#item).unbind('touchend');
},
我就是这样解决的
CheckIndex : function(e){
e.stopPropagation();
var _a = this.swipe.index+1;
this.$el.unbind('touchend'); //instead of $("#item").unbind('touchend');
},
是打字错误吗?您错过了该商品的收盘双报价
$("#item).unbind('touchend');
应该是
$("#item").unbind('touchend');
你到底想在这里实现什么?我使用了swipe.js,其中swipe项目有可以点击的子项?你能解释一下你想做什么吗,也许有另一种解决ypur问题的方法吗?不,事实上我让它起作用了。解决方案在swipe.js本身的回调函数中。谢谢你。