diff --git a/backbone.js b/backbone.js index 1b013229..e7702b48 100644 --- a/backbone.js +++ b/backbone.js @@ -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(); diff --git a/index.html b/index.html index 4f4e09a3..01768079 100644 --- a/index.html +++ b/index.html @@ -382,7 +382,7 @@
Backbone.js gives structure to your serious JavaScript web applications - by supplying models with key-value binding and custom events, + by supplying models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface. @@ -392,7 +392,7 @@ The project is hosted on GitHub, and the annotated source code is available, as well as an online test suite, - an example application, + an example application, a list of tutorials and a long list of real-world projects that use Backbone.
@@ -1036,8 +1036,9 @@ ActiveRecord::Base.include_root_in_json = false
changemodel.change()
- Manually trigger the "change" event.
- If you've been passing {silent: true} to the set function in order to
+ Manually trigger the "change" event and a "change:attribute"
+ event for each attribute that has changed. If you've been passing
+ {silent: true} to the set function in order to
aggregate rapid changes to a model, you'll want to call model.change()
when you're all finished.
Working with Rails
- Backbone.js was originally extracted from
+ Backbone.js was originally extracted from
a Rails application; 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.
By default, Rails adds an extra layer of wrapping around the JSON representation of models. You can disable this wrapping by setting:
- +-ActiveRecord::Base.include_root_in_json = false +ActiveRecord::Base.include_root_in_json = false
- ... in your configuration. Otherwise, override - parse 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 params, or - you can override toJSON in Backbone to add + ... in your configuration. Otherwise, override + parse 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 params, or + you can override toJSON in Backbone to add the extra wrapping Rails expects.