estesbubba
21 Dec 2011, 8:15 AM
Looking at several examples (Twitter, Kiva, etc.) I see this in the controllers:
views : [
'Main'
],
refs: [{
ref : 'main',
selector : 'mainview',
xtype : 'mainview',
autoCreate: true
}]
From this you automatically get getMainView() and getMain(). I'm confused on what are the best practices for using these and have several questions. We are starting two new projects and using Touch 2.0.
1. What is the preferred way to create a view in a controller? getMainView().create() or getMain()? Our controller will have several views in the card layout.
2. Is there a way to have it create the first time and reuse after that? Normally I would do if (!this.view) { this.view = Ext.create()}. With this model it appears you should always use getters instead of setting a property of the instance.
3. Does the views: [] only define references and not instances?
It appears that views and refs have some overlapping functionality but still different. Since we are starting two big 2.0 projects now I want to make sure we start out doing things right.
views : [
'Main'
],
refs: [{
ref : 'main',
selector : 'mainview',
xtype : 'mainview',
autoCreate: true
}]
From this you automatically get getMainView() and getMain(). I'm confused on what are the best practices for using these and have several questions. We are starting two new projects and using Touch 2.0.
1. What is the preferred way to create a view in a controller? getMainView().create() or getMain()? Our controller will have several views in the card layout.
2. Is there a way to have it create the first time and reuse after that? Normally I would do if (!this.view) { this.view = Ext.create()}. With this model it appears you should always use getters instead of setting a property of the instance.
3. Does the views: [] only define references and not instances?
It appears that views and refs have some overlapping functionality but still different. Since we are starting two big 2.0 projects now I want to make sure we start out doing things right.