每次我调用“this.model = new Unidade();”时,this.model 都会将最后一个值的一些值保存在那里。
this.model.id => 变为 null,但其他属性保留最后一个模型的值。
模型来源
window.Unidade = Backbone.Model.extend({
urlRoot : $urlPadrao + "cliente/externo/unidade",
defaults: { // setting defaults to null or ""
},
initialize: function () {
... // Just initialize the validators methods
},
getDefaults: function() {
// returns the same values of defaults
// since I can't get a "new" model
}
});
在我看来:
this.model = new Unidade();
// this.model may be already populated... I'm trying to create a new one
// that's the problem, it keeps some values of the last one
// Shouldn't give me a new model populate with the defaults?
为了记录,我没有弄乱原型。