[Pkg-javascript-commits] [backbone] 35/74: Added clear method to Model. Removes all attributes like you would expect.
Jonas Smedegaard
js at moszumanska.debian.org
Sat May 3 16:59:06 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.3.0
in repository backbone.
commit d84ef25c6b04a75a0f4191cc2c7970d998da1eee
Author: Chris Lloyd <christopher.lloyd at gmail.com>
Date: Sun Oct 31 22:44:19 2010 +0100
Added clear method to Model. Removes all attributes like you would expect.
---
backbone.js | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/backbone.js b/backbone.js
index 6112759..538842d 100644
--- a/backbone.js
+++ b/backbone.js
@@ -190,6 +190,22 @@
}
return value;
},
+
+ // Clears all attributes from the model, firing `"change"` unless you
+ // choose to silence it.
+ clear : function(options) {
+ options || (options = {});
+ var old = this.attributes;
+ this.attributes = {};
+ if (!options.silent) {
+ this._changed = true;
+ for (attr in old) {
+ this.trigger('change:' + attr, this);
+ }
+ this.change();
+ }
+ return old;
+ },
// Fetch the model from the server. If the server's representation of the
// model differs from its current attributes, they will be overriden,
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git
More information about the Pkg-javascript-commits
mailing list