I use this in my tutorial application to get json from a remote server and parse it into an array of objects.
App.Model.reopenClass({ allItems: [], find: function(){ $.ajax({ url: 'http://remote_address/models.json', dataType: 'json', context: this, success: function(data){ data.forEach(function(model){ this.allItems.addObject(App.Model.create(model)) <------------------- }, this) } }) return this.allItems; }, });
xamenrax
source share