1. #1
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    69
    Vote Rating
    2
    pdm is on a distinguished road

      0  

    Default 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)

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,346
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    69
    Vote Rating
    2
    pdm is on a distinguished road

      0  

    Default


    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.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,346
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    69
    Vote Rating
    2
    pdm is on a distinguished road

      0  

    Default


    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.

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,346
    Answers
    3541
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    69
    Vote Rating
    2
    pdm is on a distinguished road

      0  

    Default


    Thanks. After some hacking this is what I have:
    Code:
    onNavigationviewActiveItemChange: function(container, value, oldValue, options) {
        if (value.xtype == 'homepage'){
            container.getNavigationBar().backButtonStack = [];
        }
    }
    Seems to work fine. Anyone anticipate problems with this approach?

  8. #8
    Touch Premium Member
    Join Date
    Sep 2011
    Posts
    69
    Vote Rating
    2
    pdm is on a distinguished road

      0  

    Default


    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]);
                }
            }
        }
    }

Thread Participants: 1