-
11 Oct 2012 4:34 AM #1
Answered: problem with requiring files
Answered: problem with requiring files
Hello
When I run my app I get warnings like
Here is how I've used the SearchListItem:Code:[WARN][Anonymous] [Ext.Loader] Synchronously loading 'NS.view.template.SearchListItem'; consider adding NS.view.template.SearchListItem' explicitly as a require of the corresponding class
The warning is only gone when I require the SearchListItem in app.jsCode:Ext.define('NS.view.ItemList', { extend: 'Ext.dataview.List', requires: [ 'NS.view.template.SearchListItem'], config: { itemTpl: Ext.create('NS.view.template.SearchListItem'), ...... } });
Any suggestions ?
Cheers
-
Best Answer Posted by mitchellsimoensCode in red is invalid, you should not create an instance on a config like that, only create instances within methods like (typing off top of my head):Code:
Ext.define('NS.view.ItemList', { extend: 'Ext.dataview.List', requires: [ 'NS.view.template.SearchListItem'], config: { itemTpl: Ext.create('NS.view.template.SearchListItem'), ...... } });
Code:Ext.define('NS.view.ItemList', { extend: 'Ext.dataview.List', requires: [ 'NS.view.template.SearchListItem'], config: { itemTpl: true, ...... }, applyItemTpl : function(tpl, oldTpl) { if (tpl === true) { tpl = Ext.create('NS.view.template.SearchListItem'); } return this.callParent([tpl, oldTpl]); } });
-
13 Oct 2012 6:31 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3156
Code in red is invalid, you should not create an instance on a config like that, only create instances within methods like (typing off top of my head):Code:Ext.define('NS.view.ItemList', { extend: 'Ext.dataview.List', requires: [ 'NS.view.template.SearchListItem'], config: { itemTpl: Ext.create('NS.view.template.SearchListItem'), ...... } });
Code:Ext.define('NS.view.ItemList', { extend: 'Ext.dataview.List', requires: [ 'NS.view.template.SearchListItem'], config: { itemTpl: true, ...... }, applyItemTpl : function(tpl, oldTpl) { if (tpl === true) { tpl = Ext.create('NS.view.template.SearchListItem'); } return this.callParent([tpl, oldTpl]); } });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.
-
13 Oct 2012 7:39 AM #3
-
22 Oct 2012 10:25 AM #4
I can't get this to work in the following situation in which I create a new field type:
So, if create this component something likeCode:Ext.define('NS.view.field.CField', { extend: 'Ext.field.Field', xtype: cfield', config: { component: { xtype: 'panel', tpl: 'NS.view.field.template.CfTpl' } }, initialize: function() { this.callParent(); }, applyTpl: function(nv, ov) { this.getComponent().setTpl(Ext.create('NS.view.field.template.CfTpl') ; }, .....
So, how can I set the tpl on the component ?Code:{ xtype: 'cfield',<br> tpl: true<br> }
cheers


Reply With Quote