Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : [solved] custom service encapsulation

$
0
0
No, it makes no sense, because my question relates to custom implementation of the findOne.

In fact, 
i missed ajax parameter 'json foo.models' that makes $.ajax to call Foo.models(response) to convert data to models.
In custom non-AJAX/non-REST implementations this should be called manually.

But it is not quite clean what is difference between new Model(data) and Model.model(data)

The implementation is:
  1.     model: function( attributes ) {
  2.       if (!attributes ) {
  3.         return null;
  4.       }
  5.       if ( attributes instanceof this ) {
  6.         attributes = attributes.serialize();
  7.       }
  8.       return new this(
  9.       // checks for properties in an object (like rails 2.0 gives);
  10.       isObject(attributes[this._shortName]) || isObject(attributes.data) || isObject(attributes.attributes) || attributes);
  11.     },


Viewing all articles
Browse latest Browse all 3491

Trending Articles