Skip to content

Commit

Permalink
Updating Model-save documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Dec 23, 2010
1 parent a0ace0d commit 65e4340
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions index.html
Expand Up @@ -701,10 +701,13 @@ <h2 id="Model">Backbone.Model</h2>
</pre>

<p id="Model-save">
<b class="header">save</b><code>model.save(attributes, [options])</code>
<b class="header">save</b><code>model.save([attributes], [options])</code>
<br />
Save a model to your database (or alternative persistence layer),
by delegating to <a href="#Sync">Backbone.sync</a>. If the model has a <a href="#Model-validate">validate</a>
by delegating to <a href="#Sync">Backbone.sync</a>. The <b>attributes</b>
hash (as in <a href="#Model-set">set</a>) should contain the attributes
you'd like to change -- keys that aren't mentioned won't be altered.
If the model has a <a href="#Model-validate">validate</a>
method, and validation fails, the model will not be saved. If the model
<a href="#Model-isNew">isNew</a>, the save will be a <tt>"create"</tt>
(HTTP <tt>POST</tt>), if the model already
Expand Down Expand Up @@ -737,6 +740,10 @@ <h2 id="Model">Backbone.Model</h2>
validation fails, return a non-<tt>200</tt> HTTP response code, along with
an error response in text or JSON.
</p>

<pre>
book.save({author: "F.D.R."}, {error: function(){ ... }});
</pre>

<p id="Model-destroy">
<b class="header">destroy</b><code>model.destroy([options])</code>
Expand Down

0 comments on commit 65e4340

Please sign in to comment.