-
10 Jan 2012 10:51 AM #1
Unanswered: Can't get store CRUD methods to be called
Unanswered: Can't get store CRUD methods to be called
I have a button (on a form.Panel) with the follow tap handler:
The store->proxy handler currently only contain a console.log() statement (they are empty) except for read() which works. The moment the code above hits: 'panelRecord.save()' it kinda hangs (I don't see the console.log immediately afterwards). I have tried many things with no success. What am I doing wrong?Code:var thisController = this; var store = thisController.getContactsStore(); var cmVp = thisController.getCmViewport(); var bar = cmVp.getNavigationBar(); bar .add({ id : 'donebutton', xtype : 'button', align : 'right', text : addOrEdit, ui : 'action', listeners : { 'tap' : function(component, e, eOpts) { console .log('CM.controller.Contacts doneButton onTap'); var updatePanel = thisController .getContactUpdatePanel(); var panelRecord = updatePanel .getRecord(); if (panelRecord != null) { console .log('updating contact'); updatePanel.updateRecord( panelRecord, true); console .log('record updated'); if (panelRecord.dirty) { console .log('record is dirty'); panelRecord.save(); console .log('record saved'); store.sync(); console .log('store synced'); } else { console .log('record is not dirty, bailing'); } }
The console.log statements I see in the log are:
2012-01-10 10:42:14.451 SenchaTouch2POC[7585:fb03] [INFO] doneButton onTap
2012-01-10 10:42:14.452 SenchaTouch2POC[7585:fb03] [INFO] updating contact
2012-01-10 10:42:14.453 SenchaTouch2POC[7585:fb03] [INFO] record updated
2012-01-10 10:42:14.453 SenchaTouch2POC[7585:fb03] [INFO] record is dirty
-
10 Jan 2012 11:17 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
- Answers
- 3113
You shouldn't call save() on the model. sync() on the store will handle the saving.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Jan 2012 11:24 AM #3
thanks for the quick response. If I remove panelRecord.save(), there is no change in behavior. I never see:
and I never see the console.log() from the store->proxy->update() method. I know I have the right reference to the store because if (right before store.sync()) i do a:Code:console.log('store synced');
I see '2' in the console log which is correct, my store has 2 records. I must be missing something OBVIOUS!Code:console.log(store.getTotalCount());
-
10 Jan 2012 3:43 PM #4
there must be something I am doing wrong? Anybody out there who can help me? Do I need to post more code to provide a more complete picture?


Reply With Quote