Backbone view DOM element removed

后端 未结 3 535
我在风中等你
我在风中等你 2021-02-06 16:39

I keep reading about the Backbone.js zombie (or memory leak) problem. Basically you have to unbind and remove the element from the DOM when you no longer need it to make sure al

3条回答
  •  -上瘾入骨i
    2021-02-06 17:35

    Backbone development version(master) now exposes _removeElement()

     remove: function() {
          this._removeElement();
          this.stopListening();
          return this;
        },
    

    Remove this view’s element from the document and all event listeners attached to it. Exposed for subclasses using an alternative DOM manipulation API.

    _removeElement: function() {
          this.$el.remove();
        },
    

    http://backbonejs.org/docs/backbone.html

提交回复
热议问题