-
23 Nov 2012 7:30 AM #1
Unanswered: Weird naming convention using model and store?
Unanswered: Weird naming convention using model and store?
Dear all,
I'm using MVC. Recently I encountered a problem loading a model for a store, getting a naming error:
In the DataView declaration the abbreviation 'MyModel' is fine but for the Store declaration this results in an error "MyModel does not exist". Replacing MyModel with Test.model.MyModel fixes the problem. For me, this seems to be inconsistent. Or is there another error in my code?Code:Ext.application({ name: 'Test', views: ['MyView'], models: ['MyModel'], stores: ['MyStore'], launch: function() { Ext.Viewport.add(Ext.create('Test.view.MyView')); } }); Ext.define('Test.model.MyModel', { extend: 'Ext.data.Model', config: { fields: ... } }); Ext.define('Test.store.MyStore', { extend: 'Ext.data.Store', config: { model: 'MyModel', // error - instead 'Test.model.MyModel' is required ... ... } }); Ext.define('Test.view.MyView', { extend: 'Ext.DataView', config: { store: 'MyStore', itemTpl: ... } });
-Niko
-
23 Nov 2012 8:26 AM #2
-
26 Nov 2012 11:52 PM #3
Just a typo in the example code ... Sorry. Problem remains.
-
27 Nov 2012 12:32 AM #4
Hi Niko,
did you require your model anywhere in your code?
You can do this either in your app.js or in your store. With the help of the "require" you make sure that the given files are loaded and available for further using.
I can imagine that something like
will fix the problem.Code:Ext.define('Test.store.MyStore', { extend: 'Ext.data.Store', requires: [ 'Test.model.MyModel' ], config: { model: 'MyModel', ... } });
Best regards,
Schildi
-
27 Nov 2012 12:35 AM #5
Hi Schildi,
Yes, I did, in app.js. I added this also to my code example.
-Niko
-
27 Nov 2012 8:16 AM #6
Are the names correct in the Application
Are the names correct in the Application
Shouldn't the models and stores in the Application be : MyModel and MyStore?


Reply With Quote