PDA

View Full Version : [CLOSED]Model.save also fails...



icflorescu
16 Feb 2011, 9:15 AM
var user = Ext.ModelMgr.create({name: 'Ed Spencer', email: '[email protected]'}, 'User');
user.save(); //POST /users


This also fails with the following error:
me.getProxy() is undefined

ext-all-debug.js (line 25850):



me.getProxy()[action](operation, callback, me);

edspencer
17 Feb 2011, 4:26 AM
We need to have a better error message here. The Model has no way of knowing how to save itself without a Proxy defined (the Proxy handles all of the loading and saving). This might be helpful to you: http://www.sencha.com/blog/using-the-data-package-in-sencha-touch/

icflorescu
17 Feb 2011, 9:47 AM
Ed, thank you for your reply!

Perhaps I should have pasted my entire code:


Ext.onReady(function() {

Ext.regModel('User', {
fields: [ 'id', 'name', 'email' ],
proxy: {
type: 'rest',
url: 'data/users',
format: 'json'
}
});

var user = Ext.ModelMgr.create({name: 'User Name', email: '[email protected]'}, 'User');
user.save({
success: function() {
console.log('The user was saved');
}
});

});


As you see there is a rest proxy defined in the model...
I don't understand, considering the code above, shouldn't user.save make a POST to data/users.json? Am I forgetting something?

P.S. I think the data package looks fantastic!

evant
17 Feb 2011, 7:44 PM
Looks to be the same issue as here:

http://www.sencha.com/forum/showthread.php?124214-Models-and-Stores

Will close this one off.