Search code examples
javascriptextjsmobilesencha-touchsencha-touch-2

Implement routing in Sencha Touch 2.4.0


I am trying to implement routing in Sencha Touch 2.4.0 but am not able to fire a function on route change event. I have a main controller-

Ext.define('STPG.controller.Main', {
    extend: 'Ext.app.Controller',

    routes : {
            'home' : 'onHome'
        },

    config: {
        refs: {

        },
        control: {

        }
    },

    //called when the Application is launched, remove if not needed
    launch: function(app) {

    },
    onHome : function() {
        console.log('home controller called');
    }
});

app.js

views: [
        'Main'
    ],

    models: [],
    controllers: ['Main'],
    stores: [],

am trying-

Ext.Viewport.add(Ext.create('STPG.view.Main'));
this.redirectTo('home');

Its not calling that function.


Solution

  • You are doing a silly mistake. Just put your routes: {} inside config. And your problem solved. Happy coding!