Search code examples
extjsextjs4

How to route to a view on button click (ExtJS 6.2)


So i have created two views : one a login dialog and the other (the following) is a dashboard basically. On login click i use this.redirectTo("dashboard",true); hoping that it will trigger the routing linked handler in the next view (the following) but it didn't work; so I set the trigger manually and trigger the handler using an instance of the view.

   Ext.define('Mine.view.newDashboard', {
            extend: 'Ext.Container',
            alias: 'widget.newDashboard',
            id: 'project1',
             routes:{
                     '#dashboard':{
                         action:'onDashboardView'
                     }
                     },
             onDashboardView:function(){
                    var dash =  Ext.create('widget.newDashboard', {
                    renderTo: Ext.getBody(),
                    hideMode: 'visibility'
                 });
                              dash.show();
             },....

My question is how to do the routing properly like in the described first way so that the first displays when the URL changes to include the '#dashboard' part?

UPDATE2 : for now previous and next of the browser are doing nothing. Thanks !


Solution

  • You are making progress. Remove the hash from the routes

    Ext.define('Mine.view.newDashboard', {
                extend: 'Ext.Container',
                alias: 'widget.newDashboard',
                id: 'project1',
                 routes:{
                         'dashboard':{     // REMOVE THE #
                             action:'onDashboardView'
                         }
                         },
                 onDashboardView:function(dash){
      
                                  dash.show();
                 },....
    

    Fiddle

    Fiddle - see the url change