Backbone.js View removing and unbinding

后端 未结 4 531
轮回少年
轮回少年 2021-02-03 15:36

when my page opens, I call the collection and populate the view:

var pagColl = new pgCollection(e.models); 
var pagView = new pgView({collection: pagColl});
         


        
4条回答
  •  Happy的楠姐
    2021-02-03 16:01

    I use the stopListening method to solve the problem, usually I don't want to remove the entire view from the DOM.

    view.stopListening();
    

    Tell an object to stop listening to events. Either call stopListening with no arguments to have the object remove all of its registered callbacks ... or be more precise by telling it to remove just the events it's listening to on a specific object, or a specific event, or just a specific callback.

    http://backbonejs.org/#Events-stopListening

提交回复
热议问题