mirror of
https://github.com/jashkenas/backbone.git
synced 2026-01-24 22:37:58 -05:00
A silent change to a model will now make hasChanged() return true ... Issue #105
This commit is contained in:
10
backbone.js
10
backbone.js
@@ -180,10 +180,8 @@
|
||||
if (!_.isEqual(now[attr], val)) {
|
||||
now[attr] = val;
|
||||
delete escaped[attr];
|
||||
if (!options.silent) {
|
||||
this._changed = true;
|
||||
this.trigger('change:' + attr, this, val, options);
|
||||
}
|
||||
this._changed = true;
|
||||
if (!options.silent) this.trigger('change:' + attr, this, val, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,8 +204,8 @@
|
||||
// Remove the attribute.
|
||||
delete this.attributes[attr];
|
||||
delete this._escapedAttributes[attr];
|
||||
this._changed = true;
|
||||
if (!options.silent) {
|
||||
this._changed = true;
|
||||
this.trigger('change:' + attr, this, void 0, options);
|
||||
this.change(options);
|
||||
}
|
||||
@@ -227,8 +225,8 @@
|
||||
|
||||
this.attributes = {};
|
||||
this._escapedAttributes = {};
|
||||
this._changed = true;
|
||||
if (!options.silent) {
|
||||
this._changed = true;
|
||||
for (attr in old) {
|
||||
this.trigger('change:' + attr, this, void 0, options);
|
||||
}
|
||||
|
||||
@@ -159,6 +159,8 @@ $(document).ready(function() {
|
||||
ok(_.isEqual(model.previousAttributes(), {name : "Tim", age : 10}), 'previousAttributes is correct');
|
||||
});
|
||||
model.set({name : 'Rob'}, {silent : true});
|
||||
equals(model.hasChanged(), true);
|
||||
equals(model.hasChanged('name'), true);
|
||||
model.change();
|
||||
equals(model.get('name'), 'Rob');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user