Backbone stopListening

时间:2014-09-30 06:29:42

标签: backbone.js

据我所知,view.remove()函数会自动调用stopListening()。但是,如果未调用posts:open,则事件this.collection.stopListening()无法取消绑定。请帮忙缺少什么?我想我想念一些东西。

// posts.js - Collection
this.listenTo(App, 'posts:open', function() { console.log("hello world"); } );

// posts-item-view.js - ItemView
events: { "click #open", "this.open"},

open: function() {
    App.trigger('posts:open', this.model);
}

// posts-com-view.js - CompositeView
destroy: function() {
    //if (this.collection) {
    //  this.collection.stopListening();
    //}

    this.remove();
},

0 个答案:

没有答案