4

グローバルイベントバスに追加したイベントは、呼び出すことで削除されview.unbindAll()ますか?

4

1 に答える 1

6

bindToマリオネットビュータイプのメソッドでそれらをバインドする場合、はい:


SomeView = Backbone.Marionette.ItemView.extend({

  initialize: function(){
    // note the use of the 4th parameter. this is important when binding
    // to the App's event aggregator
    this.bindTo(MyApp.vent, "some:event", this.someCallback, this);
  },

  someCallback: function(){
    // ...
  }
});

SomeViewのインスタンスを閉じると、イベントアグリゲーターイベントのバインドが解除されます。

于 2012-06-20T12:01:35.470 に答える