Skip to content

@braddunbar /gist:1718983 forked from Douglasj/gist:1718943
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Backbone previous attributes question
var Backbone = require('backbone'),
M = Backbone.Model.extend(),
t = new M({
var1: 'a',
var2: 'b'
});
console.log(t.toJSON()); // {var1: 'a', var2: 'b'}
t.set({ var1: 'b' }, {silent: true});
console.log(t.hasChanged()); // true
console.log(t.previousAttributes()); // {var1: 'a', var2: 'b'}
console.log(t.changedAttributes()); // {var1: 'b'}
t.on('change', function() {
console.log(t.hasChanged('var1')); // true
});
t.change();
console.log(t.hasChanged()); // false
console.log(t.previousAttributes()); // {var1: 'b', var2: 'b'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.