Skip to content

Commit

Permalink
Fix document for Model#validate
Browse files Browse the repository at this point in the history
  • Loading branch information
hokaccha committed Jan 20, 2013
1 parent 87ee87d commit 062f020
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ <h2 id="Model">Backbone.Model</h2>
error object that describes the error programmatically. If <b>validate</b>
returns an error, <tt>set</tt> and <tt>save</tt> will not continue, and the
model attributes will not be modified.
Failed validations trigger an <tt>"error"</tt> event.
Failed validations trigger an <tt>"invalid"</tt> event.
</p>

<pre class="runnable">
Expand All @@ -1299,30 +1299,21 @@ <h2 id="Model">Backbone.Model</h2>
title : "Chapter One: The Beginning"
});

one.on("error", function(model, error) {
one.on("invalid", function(model, error) {
alert(model.get("title") + " " + error);
});

one.set({
one.save({
start: 15,
end: 10
});
</pre>

<p>
<tt>"error"</tt> events are useful for providing coarse-grained error
messages at the model or collection level. An <tt>error</tt> callback can
can also be specified in the options, to be called alongside the error event:
<tt>"invalid"</tt> events are useful for providing coarse-grained error
messages at the model or collection level.
</p>

<pre>
account.set({access: "unlimited"}, {
error: function(model, error) {
alert(error);
}
});
</pre>

<p id="Model-url">
<b class="header">url</b><code>model.url()</code>
<br />
Expand Down

0 comments on commit 062f020

Please sign in to comment.