1

重複の可能性:
Backbone.js ビューでイベントのバインドを適切に解除できない

インジケータにも swipe.js があるため、touchend のイベントリスナーを持つ Item という名前の div があります。現在、 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');
}, 
4

2 に答える 2

2

これが私がそれを解決した方法です。

CheckIndex : function(e){
  e.stopPropagation();
  var _a = this.swipe.index+1;
  this.$el.unbind('touchend'); //instead of $("#item").unbind('touchend');
}, 
于 2012-06-13T07:47:09.937 に答える
0

タイプミスですか?item の終了二重引用符がありませんでした

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

する必要があります

$("#item").unbind('touchend'); 
于 2012-06-13T07:54:22.483 に答える