include()methods to add class and instance methods respectively.
- New declaration syntax - pass a function giving you access to the newly created class instead of two separate objects.
- A model with an id will be added to the collection when saved (like the docs said originally).
count()now follows suit with the rest of js-model and returns the number of models in
all()allowing you to overwrite
all()with your own custom implementation - or "Eggs Fish Ham" as he put it ;) [Mark Evans]
- Protect the collection from accidental modification allowing you to safely
remove()a model from within an
- Added configurable Model.unique_key, exposed as instance.id() and used in finders. Defaults to 'id'. [Ismael Celis and Oliver Nightingale]
- Protect an instance's initial attributes from accidental modification.
- Add the ability to define a custom
initialize()instance method that is called at the end of the initialization process. Thanks to Ismael Celis for the idea.
- Ajax DELETE sends JSON body, including AjaxSetup data if available. [Ismael Celis]
Model.remove()should include removed instance in event data. [Ismael Celis]
- Call the
Model.load()callback with the scope of the class.
- If defined, include jQuery.ajaxSetup data in REST parameters. [Ismael Celis]
- Finder methods now return
undefinedfor a missing model.
- Remove #update method which you might guess acts like ActiveRecord's #update_attributes which is not the case - no calls are triggered on the persistence adapter.
- Model.RestPersistence renamed to Model.REST - Model.RestPersistence can still be used but will be removed in version 1.0.
- REST adapter now sends JSON instead of "application/x-www-form-urlencoded" (and so now requires the browser to be JSON-aware).
- Add Model.VERSION to allow inspection of js-model version.
- Add Model.localStorage persistence adapter.
- Stop jQuery's JSON parsing throwing an error when encountering Rails' none-empty " " JSON responses.
- Remove Underscore dependency.
Model.removemethod now takes a model instance rather than an id.
sortByand add the ability to specify an attribute name as well as a custom function. Add
sortmethod that acts on a collection just like
pluckmethod that takes an attribute name and returns an array of values.
- Fix for callbacks being wrongly called on multiple instances - they were being stored on the prototype and thus being shared across instances. Thanks to Oliver Nightingale for identifying the bug and writing a test case.
- Add named parameters to
Model.RestPersistenceso "/categories/:category_id/posts" will pick up the corresponding
category_idattribute from your model and be converted to "/categories/2/posts". [Russell Jones]
- Fix that
nullwhen nothing is found.
unbindmethod to unbind all callbacks for a particular event or a specific callback by passing a reference to the original function.
- Move callback functionality into a separate module and mix-in to class and instance.
- Don't log an error when Rails returns a response of " " for a
dataType"json" removing the need to set a global
beforeSend. [Jason Lee]
- Fix that custom class methods should be available after chaining.
- Move model collection methods into a separate object allowing you to customise the defaults in a single place.
- Move model instance methods into a separate object. This allows you to redefine the defaults once rather than having to pass the same custom method to multiple models at declaration time.
- Defining a model now takes three arguments: name, class methods, instance methods.
- Fix callbacks in IE.
- Fix broken Ajax tests in IE6 and IE7.
Model.RestPersistencenow recognises a 422 response as validation failure and populates the model's errors object with the response data.
Model.errorsis now an object and has a similar interface to ActiveModel.
- Fix that
changesshould only be merged after a successful
- Calling Model#attr() with no arguments returns a combined object of attributes/changes.
- Fix that
Model.RestPersistenceAjax failures should correctly run the supplied callback.
- Collection methods now access the collection through the
allmethod so that
each, etc work as expected if it's overwritten.
- Events are now bound directly to a model rather than using jQuery
bind. Collections also now have the concept of events with "add" and "remove" built-in.
updateshould trigger "update" event, add separate
- Fix that persistence failure should not trigger corresponding event.
- Pass only a single callback to save/destroy which is called with a boolean to indicate success/failure.
- Change behaviour of
Model.Collectionand don't let duplicates (scoped by id) of the same model to be stored. [Laurie Young]
- Fix that setting a null value with
attrshould be read back correctly from
errorsarray shouldn't have to be manually
- First tagged release.