$.Model is the application data layer. It provides an easy way to connect to the services that provide RESTful APIs, listen to data changes, and bind HTML elements to models, deferrers, and validations.
$.Model is very handy; we don't need to manually write XHR calls using jQuery's Ajax method for instance. We can map our backend API using $.Model and then use its methods to pull/push data to the server.
We can organize $.Models with a list using $.Model.List
, which is similar to Backbone.js's collections (http://backbonejs.org/#Collection).
Let's write some code in the file jquerymx_playground_1.js
:
steal( 'jquery/model', 'jquery/dom/fixture', function ($) { $.Model('AccountModel', { findAll: 'GET /accounts', findOne: 'GET /accounts/{id}', create: 'POST /accounts', update: 'PUT /accounts/{id}', destroy: 'DELETE /accounts/{id}' }, { } ); ...