I am using NavigationView as root panel. And what I'm trying to accomplish is to click views on my root panel when the user dives deeper into my application and pops up when the user returns.
Here are simple examples showing my problem: I have one view view showing some data about a record.
Ext.define('MyApp.view.EntryDetails', { extend: 'Ext.Panel', xtype: 'entrydetails', config: { tpl: '<div>{id}</div>' } });
I also have a controller configured to listen on the following route: "entry /: id" and click on the new entrydetails view on the navigation table (NavigationView) when that route matches.
Ext.define('MyApp.controller.EntryDetails', { extend: 'Ext.app.Controller', config: { routes: { 'entry/:id': 'showEntry' }, refs: { navview: 'mynavigationview' }, }, showEntry: function(id){ this.getMain().push({ xtype: 'entrydetails', data: {id:id} }); } });
Ok, this works fine. Now let's first assume that I go to: index.html # entry / 1. This will push the new presentation onto the stack as I want. Then I click on another link index.html # entry / 2. Another view is pushed onto the stack; this is also the intended behavior. Now the problem occurs when I click the "BROWSERS back" button. This changes the url to index.html # entry / 1 and pops another view onto my stack. I wanted to expose the view instead of adding another. If I click the toolbar button, the view opens as I wanted, but this does not apply to the browsers return button.
I understand why this is happening: Sencha touch does not know if the URL change has changed by clicking another link with the same URL as the previous browser history URL, or if I click the back button on my browser. And all my code knows is that he should push another view onto the stack when he sees the URL change to "entry /: id".
What is the best way to solve this problem. How to determine that the back button of the browser has been pressed, and pop view from my navigation mode.
I thought about checking if the changed URL was a more detailed simulator in my navigation stack, but I'm not sure if this is the way to do it.
Any help / discussion on this topic is welcome!