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

Why use Models.model()

$
0
0
Hello,

I wanted to know why one would use Models.model()? I understand that this function converts data into a $.List of $.Model instances but I don't understand when you would want to do this or why. As per the example: http://v3.javascriptmvc.com/docs/jQuery.Model.html#&who=jQuery.Model.static.models

My service call looks like this:

$.Model('MyModel',
/* @Static */
{    
   models : function(data){               
      return this._super(data);
},
   
getMyModels : function(args) {
   return $.ajax( {
      context : args.context,
      url :'/get/my/models',
      type : 'get',
      contentType : 'application/json',
      dataType : 'json',
      success : args.success,
      error : args.error,
      cache : false
});

//...

The service call:

MyModel.getMyModels({
   success :function(data){
      var myStuff = MyModels.models(data.myModels);
      // do stuff with myStuff
   }
  context : $('#my_stuff'),
  error : function(jqXHR, textStatus, errorThrown){ console.log(textStatus); }
});


Thanks for any explanation,

Jason

Viewing all articles
Browse latest Browse all 3491

Trending Articles