[Pkg-javascript-commits] [backbone] 189/211: expanded Model.save example

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.5.0
in repository backbone.

commit 2ed2af6698a23a36eb0de976ab840c97e39c9772
Author: Loren Sands-Ramshaw <lorensr at gmail.com>
Date:   Sat Jun 18 17:20:27 2011 -0400

    expanded Model.save example
---
 index.html | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/index.html b/index.html
index b879589..e9a85f3 100644
--- a/index.html
+++ b/index.html
@@ -758,13 +758,16 @@ setInterval(function() {
     </p>
 
     <p>
-      In the following example, notice how because the model has never been
-      saved previously, our overridden version of <tt>Backbone.sync</tt> receives a <tt>"create"</tt> request.
+      In the following example, notice how our overridden version
+      of <tt>Backbone.sync</tt> receives a <tt>"create"</tt> request
+      the first time the model is saved and an <tt>"update"</tt>
+      request the second time.
     </p>
 
 <pre class="runnable">
 Backbone.sync = function(method, model) {
   alert(method + ": " + JSON.stringify(model));
+  model.id = 1;
 };
 
 var book = new Backbone.Model({
@@ -773,6 +776,10 @@ var book = new Backbone.Model({
 });
 
 book.save();
+
+book.save({
+  author: "Teddy"
+});
 </pre>
 
     <p>

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