-
12 Sep 2012 11:42 PM #1
Answered: separate (static) HTML from your view classes
Answered: separate (static) HTML from your view classes
Hi
I was wondering if there is a good way to have your (static) HTML separated from your view classes.
For example, for dynamic HTML you can put this in a XTemplate class and put all these classes in their own directory (inside the view directory). But how to do this with static HTML, the XTemplate sounds like overkill ?
Furthermore, I do see some opportunities for inheritance here too!Code:Ext.define('My.view.Panel', { extend: 'Ext.Pabel', config: { items: [ { html: '<div>Hello</div>' }, { html: '<div>Hello again</div>' } ] } });
Thanks
Luca
-
Best Answer Posted by mitchellsimoensIn app.js:Code:
Ext.define('My.view.templates.Intro', { singleton : true, config : { html : '<div>hello</div>' }, constructor : function(config) { this.initConfig(config); this.callParent([config]); } });
Now in your class you can useCode:Ext.Loader.setPath('My', 'app'); Ext.require('My.view.templates.Intro');
Code:My.view.templates.Intro.getHtml();
-
16 Sep 2012 4:36 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
- Answers
- 3107
You can use a utility class and require it and it will be available before the classes are defined.
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.
-
16 Sep 2012 11:16 PM #3
So you mean something like this:
And use it likeCode:Ext.define('My.view.templates.Intro', { statics: { html: '<div>hello</div>' } }) ;
But maybe it would be better to create one utility class for all static html. But how/where would you initilize this (I'm using the MVC application structure)?Code:Ext.define('My.view.Panel', { extend: 'Ext.Panel', require: ['My.view.templates.Intro'], config: { items: [ { html: My.view.template.Intro.html } ] } }) ;
Cheers
Luca
-
17 Sep 2012 4:33 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,641
- Vote Rating
- 434
- Answers
- 3107
In app.js:Code:Ext.define('My.view.templates.Intro', { singleton : true, config : { html : '<div>hello</div>' }, constructor : function(config) { this.initConfig(config); this.callParent([config]); } });
Now in your class you can useCode:Ext.Loader.setPath('My', 'app'); Ext.require('My.view.templates.Intro');
Code:My.view.templates.Intro.getHtml();
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.
-
17 Sep 2012 4:35 AM #5


Reply With Quote