[Pkg-javascript-commits] [backbone] 17/74: Ensuring the Todo model has a sane default

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:59:05 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 0f1e84f6a95c53b92cf23e36e76e487a530720e6
Author: Jeff Larson <thejefflarson at gmail.com>
Date:   Mon Oct 25 17:36:58 2010 -0400

    Ensuring the Todo model has a sane default
---
 examples/todos/todos.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/examples/todos/todos.js b/examples/todos/todos.js
index a4548ca..aa2b4e1 100644
--- a/examples/todos/todos.js
+++ b/examples/todos/todos.js
@@ -5,7 +5,12 @@ $(function(){
 
   // Our basic **Todo** model. Has `content`, `order`, and `done` attributes.
   window.Todo = Backbone.Model.extend({
-
+    
+    // Ensure each todo is created with the content field filled in.
+    initialize : function(){
+      if(!this.get("content")) this.set({"content": "New Todo"}, {silent:true})
+    },
+    
     // Toggle the `done` state of this todo item.
     toggle: function() {
       this.save({done: !this.get("done")});

-- 
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