Recriando uma visão removida no backbone js
A função View.remove () no backbone js remove o elemento container da própria view do DOM impedindo a recriação das views que foram removidas. Qualquer ideia de como esse cenário é tratado
Aqui está o meu código
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();
As duas últimas linhas acima não recriam a visualização, pois a div com id = "attrs" não está mais lá.