model.previous

previousmodel.previous(attribute)
During a "change" event, this method can be used to get the previous value of a changed attribute.

1
2
3
4
5
6
7
8
9
var bill = new Backbone.Model({
  name: "Bill Smith"
});
 
bill.on("change:name", function(model, name) {
  alert("Changed name from " + bill.previous("name") + " to " + name);
});
 
bill.set({name : "Bill Jones"});
doc_Backbone
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.