-
24 Jan 2012 1:01 PM #1
PR4: Model.load() broken
PR4: Model.load() broken
This used to work in PR3 (with the config not wrapped of course):
In PR4 this makes ST log the error "An Operation needs to have a model defined."Code:Ext.define('fitmob.model.Post', { extend: 'Ext.data.Model', config: { idProperty: 'path', fields: ['path', 'parentUrl', 'pagingEnabled', 'content', 'nav'], proxy: { type: 'jsonp', url: 'http://www.fortis-it.de/cms/wp-admin/admin-ajax.php?action=fma_post' } } ... Post.load(path, { scope: this, success: function (post) { } });
From looking at the sources I found a silly workaround:
Code:Post.load(path, { model: Post, scope: this, success: function (post) { } });
ExtJS 4 plugins:
varheaders - short/normal/long column header
clearbutton - mouseover clear button in text field
Blog: fit4dev
ExtJS User Group Hamburg
-
24 Jan 2012 1:36 PM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,658
- Vote Rating
- 14
Thank you for the report and test case.
-
24 Jan 2012 2:07 PM #3
Thx for the workaround. I got the same error and my first thought was on having a wrong configuration.
But after I went with your workaround I'm seeing another error.
Uncaught TypeError: Cannot call method 'getId' of undefined
This error occurs in buildUrl method. The record object is undefined!
Code:buildUrl: function(request) { var me = this, operation = request.getOperation(), records = operation.getRecords() || [], record = records[0], format = me.getFormat(), url = me.getUrl(request), // @TODO: put back the operation id //id = record ? record.getId() : operation.id, id = record.getId();
-
25 Jan 2012 1:35 AM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 5
Thanks for the report. This will be fixed in the beta.
-
25 Jan 2012 2:51 AM #5
Something similar happens with store. I need to set the model when setting new proxy to a memory store, even though it has been set in the store config property. This happened after migrating from PR3 to PR4
Code:myStore.setProxy({ type:'memory', model: 'MyModel', data: quests, reader: { type: 'json', rootProperty: 'items' } });
-
25 Jan 2012 10:28 AM #6
Same problem with operation in PR4
Same problem with operation in PR4
I ran into the same problem using operations.
The model property was not required in PR3.Code:// Setup the read operation operation = new Ext.data.Operation({ model: model, // ST4 code or documentation bug action: 'read' });
-
25 Jan 2012 10:41 AM #7Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 5
This has been fixed and will be part of the Beta.Code:Post.load(path, { scope: this, success: function (post) { } });
This has also been made so you don't need to set the model in the config passed to setProxy().Code:myStore.setProxy({ type:'memory', model: 'MyModel', data: quests, reader: { type: 'json', rootProperty: 'items' } });
In the case where you define an operation yourself manually, we require you to specify the Model that the operation is going to be handling. In the refactored data package, Operations take care of handling any type of response (update, destroy, read, create). In order to do this, they need to know which Model they are dealing with. I have updated the documentation to explain this.
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1538
in
2.0.


Reply With Quote
