1. #1
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    93
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    Default Unanswered: Navigation View and Routes

    Unanswered: Navigation View and Routes


    I have a set of links setup in a NavigationView mapped to corresponding controllers. Right now the routes just push a view onto the NavigationView, however when I click back and try to execute the route again it isn't fired.

    To replicate:

    Code:
    Ext.define('Playground.view.MainMenu', {    extend : 'Ext.navigation.View',
        alias : 'widget.mainmenu',
    
    
        config : {
            items : [ {
                xtype : 'container',
                title : 'Playground',
    
    
                html : [ '<p><a href="#map"/>Map Link</a></p>',//...more links
                                     ].join(""),
            } ]
        }
    });
    
    Ext.define('Playground.controller.Map', {
        extend : 'Ext.app.Controller',
    
    
        config : {
            refs : {
                // View References
                mainMenu : 'mainmenu',        },
    
    
            routes : {
                'map' : 'showMap',
            }
        },
    
    
        showMap : function() {
            this.getMainMenu().push({
                xtype : 'mapview'
            });
        },
    });
    Then in a view add an anchor tag like <a href="#map">Map</a>. When you click the link it will push the map onto the view and provide a back button perfectly. But when you click back and try to click 'Map' again the showMap function is never called. The url in my browser still reads /#map also.

    Is there any configuration I missed to have the url reset? Or has someone already come up w/a clever way around this?

    Thanks much!

    Brad

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    898
    Answers
    3575
    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 need to update the hash when you go back. TouchStyle example is a good example of using routes within navigation view.
    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
    Sencha User
    Join Date
    Feb 2012
    Location
    Illinois
    Posts
    93
    Vote Rating
    2
    bwags is on a distinguished road

      0  

    Default Grabbing the window.history?

    Grabbing the window.history?


    Looking around there are window.history.replaceState or window.history.pushState that look like they should do what I am looking for but it doesn't seem to be working as expected. I assume because the NavigationView is managing the window.history.

    Code:
    		var pound = window.location.href.indexOf('#');
    
    
    		this.getMainMenuView().push({
    			xtype : 'mapview'
    		});
    
    
    		window.history.replaceState(null, null, window.location.href.substring(0,
    				pound));
    Like I said this makes the url look as I would expect but not behave as I would expect. Clicking back then on the map link again still does not work.

    Thanks,

    Brad

  4. #4
    Sencha - Training Team
    Join Date
    Nov 2009
    Location
    Washington, DC
    Posts
    62
    Vote Rating
    2
    Answers
    1
    sdruckerfig is on a distinguished road

      0  

    Default


    I wrote a blog post that explains the process...http://wp.me/pUkrJ-vA

Thread Participants: 2