Skip to content

Commit

Permalink
documentation for jashkenas#893
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Jan 27, 2012
1 parent 0d6e5f3 commit db12a23
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
3 changes: 2 additions & 1 deletion backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@
return this.id == null;
},

// Call this method to manually fire a `change` event for this model.
// Call this method to manually fire a `"change"` event for this model and
// a `"change:attribute"` event for each changed attribute.
// Calling this will cause all objects observing the model to update.
change: function(options) {
var changes = this.changedAttributes();
Expand Down
29 changes: 15 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@

<p>
Backbone.js gives structure to your serious JavaScript web applications
by supplying <b>models</b> with key-value binding and custom events,
by supplying <b>models</b> with key-value binding and custom events,
<b>collections</b> with a rich API of enumerable functions,
<b>views</b> with declarative event handling, and connects it all to your
existing API over a RESTful JSON interface.
Expand All @@ -392,7 +392,7 @@
The project is <a href="http://github.com/documentcloud/backbone/">hosted on GitHub</a>,
and the <a href="docs/backbone.html">annotated source code</a> is available,
as well as an online <a href="test/test.html">test suite</a>,
an <a href="examples/todos/index.html">example application</a>,
an <a href="examples/todos/index.html">example application</a>,
a <a href="https://github.com/documentcloud/backbone/wiki/Tutorials%2C-blog-posts-and-example-sites">list of tutorials</a>
and a <a href="#examples">long list of real-world projects</a> that use Backbone.
</p>
Expand Down Expand Up @@ -1036,8 +1036,9 @@ <h2 id="Model">Backbone.Model</h2>
<p id="Model-change">
<b class="header">change</b><code>model.change()</code>
<br />
Manually trigger the <tt>"change"</tt> event.
If you've been passing <tt>{silent: true}</tt> to the <a href="#Model-set">set</a> function in order to
Manually trigger the <tt>"change"</tt> event and a <tt>"change:attribute"</tt>
event for each attribute that has changed. If you've been passing
<tt>{silent: true}</tt> to the <a href="#Model-set">set</a> function in order to
aggregate rapid changes to a model, you'll want to call <tt>model.change()</tt>
when you're all finished.
</p>
Expand Down Expand Up @@ -2964,28 +2965,28 @@ <h2 id="faq">F.A.Q.</h2>
<p id="FAQ-rails">
<b class="header">Working with Rails</b>
<br />
Backbone.js was originally extracted from
Backbone.js was originally extracted from
<a href="http://www.documentcloud.org">a Rails application</a>; getting
your client-side (Backbone) Models to sync correctly with your server-side
(Rails) Models is painless, but there are still a few things to be aware of.
</p>

<p>
By default, Rails adds an extra layer of wrapping around the JSON representation
of models. You can disable this wrapping by setting:
</p>

<pre>
ActiveRecord::Base.include_root_in_json = false
ActiveRecord::Base.include_root_in_json = false
</pre>

<p>
... in your configuration. Otherwise, override
<a href="#Model-parse">parse</a> to pull model attributes out of the
wrapper. Similarly, Backbone PUTs and POSTs direct JSON representations
of models, where by default Rails expcects namespaced attributes. You can
have your controllers filter attributes directly from <tt>params</tt>, or
you can override <a href="#Model-toJSON">toJSON</a> in Backbone to add
... in your configuration. Otherwise, override
<a href="#Model-parse">parse</a> to pull model attributes out of the
wrapper. Similarly, Backbone PUTs and POSTs direct JSON representations
of models, where by default Rails expcects namespaced attributes. You can
have your controllers filter attributes directly from <tt>params</tt>, or
you can override <a href="#Model-toJSON">toJSON</a> in Backbone to add
the extra wrapping Rails expects.
</p>

Expand Down

0 comments on commit db12a23

Please sign in to comment.