在骨干JS的View.remove()函数将删除DOM从重现已经被去除的观点防止视图本身的容器元素。 任何想法,这种情况下如何处理
这里是我的代码,
var AttributeView = Backbone.View.extend({
el: $("#attrs"),
template:_.template($('#attrs-template').html()),
initialize:function() {
},
render:function (eventName) {
$(this.el).html(this.template(this.model.toJSON()));
return this;
},
dispose:function(eventName){
this.unbind();
this.remove();
},
});
var attrView = new AttributeView();
....
attrView.dispose();
//Later on some event I do the below
attrView = new AttributeView()
attrView.render();
最后两行以上不重新创建视图与ID =“ATTRS”股利是不再存在。