PDA

View Full Version : [FIXED] Store throwing an error when syncing with REST proxy



justinKohactive
3 Nov 2011, 10:46 AM
Controller:

onPanelHide: function(pnl, eobj) {
console.log('on hide');
var profile = Ext.data.StoreManager.lookup('Profile');



if (profile.getUpdatedRecords().length > 0) {
profile.sync();
}
}

Model:


Ext.define('LegalProxy.model.Profile', {
extend: 'Ext.data.Model',
hasMany: ['Locations', 'Expertises'],
idProperty: '_id',
fields: [
{name: '_id', type: 'string'},
{name: 'firstName', type: 'string'},
{name: 'lastName', type: 'string'},
{name: 'company', type: 'string'},
{name: 'address', type: 'string'},
{name: 'address2', type: 'string'},
{name: 'city', type: 'string'},
{name: 'state', type: 'string'},
{name: 'zipcode', type: 'int'}
],
proxy: {
type: 'rest',
url: endpoint + '/profiles'
}

});


Store:


Ext.define('LegalProxy.store.Profile', {
extend : 'Ext.data.Store',
model : 'LegalProxy.model.Profile',
storeId : 'profileStore',
requires: ['LegalProxy.model.Profile']
});



Data loads fine into the store, and its marked dirty and as a updatedRecord, but when I call sync i get:

all-debug.js:21515 Uncaught TypeError: Cannot call method 'update' of undefined

Jamie Avins
3 Nov 2011, 11:30 AM
Thank you for the report.

justinKohactive
3 Nov 2011, 11:51 AM
As a work around:


if (profile.getUpdatedRecords().length > 0) {
Ext.each(profile.getUpdatedRecords(), function(it, index, profile) {
it.save();
});
}

seems to accomplish what I was looking for.

TommyMaintz
6 Jan 2012, 9:56 AM
This has been fixed and will be part of the next Touch 2.0 release. Thanks again for the report!