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
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