-
11 Jan 2012 11:49 AM #1
Answered: Move between cards in card layout properly
Answered: Move between cards in card layout properly
I am using the following code to switch between my cards.
Although on every call a new instance of this xtype seems to be created. What do I have to change to show the previously created instance of this xtype instead of creating a new one?Code:Ext.Viewport.setActiveItem({ xtype: 'searchDetail' });
Cheers,
Nade
-
Best Answer Posted by mitchellsimoens
If you pass in a config object which this is:
Then it will always create a new instance of that. If you want to switch to an already created instance, you should pass the index, id, or the instance of the item to setActiveItem...Code:{ xtype : 'container' }
Code:var cnt = view.down('container'); //this uses ComponentQuery to resolve a container view.setActiveItem(cnt);
-
11 Jan 2012 12:37 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
If you pass in a config object which this is:
Then it will always create a new instance of that. If you want to switch to an already created instance, you should pass the index, id, or the instance of the item to setActiveItem...Code:{ xtype : 'container' }
Code:var cnt = view.down('container'); //this uses ComponentQuery to resolve a container view.setActiveItem(cnt);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.
-
11 Jan 2012 1:39 PM #3
Thank you, I did it this way and it works properly. Do you have any suggestions to improve it, otherwise the ticket can be marked as solved.
Code:var cnt = Ext.Viewport.down('searchDetail'); if(cnt) { Ext.Viewport.setActiveItem(cnt); } else { Ext.Viewport.setActiveItem({xtype: 'searchDetail'}); }
-
11 Jan 2012 1:46 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
- Answers
- 3102
Little better but you primarily had it!
Code:var cnt = Ext.Viewport.down('searchDetail'); if (!cnt) { cnt = { xtype : 'searchDetail' }; } Ext.Viewport.setActiveItem(cnt);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.


Reply With Quote