Hacker Newsnew | comments | show | ask | jobs | submitlogin
davej 892 days ago | link | parent

Changelog

* Creating and destroying models with create and destroy are now optimistic by default. Pass {wait: true} as an option if you'd like them to wait for a successful server response to proceed.

* Two new properties on views: $el — a cached jQuery (or Zepto) reference to the view's element, and setElement, which should be used instead of manually setting a view's el. It will both set view.el and view.$el correctly, as well as re-delegating events on the new DOM element.

* When you don't know the key in advance, you may now call model.set(key, value) as well as save.

* Multiple models with the same id are no longer allowed in a single collection.

* Added a "sync" event, which triggers whenever a model's state has been successfully synced with the server (create, save, destroy).

* bind and unbind have been renamed to on and off for clarity, following jQuery's lead. The old names are also still supported.

* A Backbone collection's comparator function may now behave either like a sortBy (pass a function that takes a single argument), or like a sort (pass a comparator function that expects two arguments). The comparator function is also now bound by default to the collection — so you can refer to this within it.

* A view's events hash may now also contain direct function values as well as the string names of existing view methods.

* Added shuffle and initial to collections, proxied from Underscore.

* Model#urlRoot may now be defined as a function as well as a value.

* View#attributes may now be defined as a function as well as a value.

* Calling fetch on a collection will now cause all fetched JSON to be run through the collection's model's parse function, if one is defined.

* You may now tell a router to navigate(fragment, {replace: true}), which will either use history.replaceState or location.hash.replace, in order to change the URL without adding a history entry.

* Within a collection's add and remove events, the index of the model being added or removed is now available as options.index.

* Added an undelegateEvents to views, allowing you to manually remove all configured event delegations.

* Although you shouldn't be writing your routes with them in any case — leading slashes (/) are now stripped from routes.




Guidelines | FAQ | Lists | Bookmarklet | DMCA | News News | Bugs and Feature Requests | Y Combinator | Apply | Library | Contact

Search: