I am building my first app with ST2 and began by building the app outlined in Getting Started with Sencha Touch 2 and then taking that and trying to modify it so it met my own needs. The demo app has a DataView List where each element can be tapped to reveal a corresponding detail page.
In that app the content on the detail pages is being pulled in dynamically and does not need to be styled or arranged much. However, for my own detail pages I need to use a Template or XTemplate to style and position my data.
I can’t seem to figure out where I should define the template (ie, var myTpl = new Ext.XTemplate(…)) —In the controller, in the model?
Any guidance on this front would be much appreciated.
This depends on where you want to use the XTemplate. If it is only ever going to be used in one view, then just define the xtemplate when you defined the view.
If you are going to use it in multiple views, then you can create a class that has a sole purpose of sharing templates.
This way the template only gets compiled once and is re-useable.