-
23 Jan 2013 7:32 AM #1
Unanswered: Navigation View reset() to arbitrary panel
Unanswered: Navigation View reset() to arbitrary panel
I'm trying to use Ext.navigation.View to present a login panel for first-time users, followed by a 'home page' panel. Then the user goes through a series of steps, and at the end, is taken back to the home page.
Every time the user goes to the home page I want to clear the history, so the user can't go back through steps they already completed, and so the framework can destroy old views.
So the login panel is only the first on the stack for the first use, then I want home page to be first on the stack.
Is there a way to clear the navigation view items so that I can insert the home page as the first item and reset() from then on? Or should I be using some other method to show my login view panel, and always have homepage as the first view pushed on to the navigation view?
(It looks wrong if I literally do that and immediately push login view: then I can go back without having logged-in)
-
25 Jan 2013 6:29 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3155
Any time you go back, it will remove the items automatically. When you remove an item, by default it will destroy those items. So if you reset() then all the items besides the first one (the now active item) will be destroyed.
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.
-
25 Jan 2013 7:11 AM #3
thanks Mitchell
The problem is I want to reset() to a different point once logged-in. Simplified example:
[0] login
[1] homepage
[2] record
on 'record' I have a button 'done', where I want to reset() to homepage. I don't want a back button on homepage because it would log out.
-
25 Jan 2013 8:35 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3155
The reset method will always go back to the first item, in this case your login page. You need to use the pop method. It can take number to go back or a ComponentQuery selector
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.
-
25 Jan 2013 8:42 AM #5
No, I need the homepage to no longer have a back button. I want to reset the navigation view so that homepage is the first.
If I just pop to homepage, login is still at [0] and 'back' button is still showing and able to go back to login.
-
25 Jan 2013 8:46 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3155
You can listen for the activeitemchange event on the nav view and if the new item is the active, hide the back button on the nav bar.
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.
-
25 Jan 2013 9:11 AM #7
Thanks. After some hacking this is what I have:
Seems to work fine. Anyone anticipate problems with this approach?Code:onNavigationviewActiveItemChange: function(container, value, oldValue, options) { if (value.xtype == 'homepage'){ container.getNavigationBar().backButtonStack = []; } }
-
4 Feb 2013 6:30 AM #8
There was a problem with that approach - sometimes the stack would be emptied when it shouldn't by going back and forth between one view and homepage. Also any views added before would stay in memory and not get destroyed. So I have revised to this:
Code:onNavigationviewActiveItemChange: function(container, value, oldValue, options) { if (value.xtype == 'homepage'){ var items = container.getInnerItems(); var index = items.indexOf(value); if (index){ // Don't remove if homepage is already first in the stack var toRemove = items.splice(0,index); var nav_bar = container.getNavigationBar(); // Remove from back button list nav_bar.backButtonStack.splice(0,index); // Remove from container for (i = 0; i < toRemove.length; i++) { container.remove(toRemove[i]); } } } }


Reply With Quote