Odtwarzanie usuniętego widoku w js sieci szkieletowej
Funkcja View.remove () w rdzeniu js usuwa z kontenera element samego widoku z DOM, uniemożliwiając odtworzenie usuniętych widoków. Każdy pomysł, jak ten scenariusz jest obsługiwany
Oto mój kod,
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();
Ostatnie dwie linie powyżej nie odtwarzają widoku, ponieważ div z id = „attrs” już nie istnieje.