Inside my Sencha Touch controller, I am selecting my views, using refs:

config: {

refs: {
    HomeView: 'HomeView',
    LoginView: 'LoginView',
    ProductsView: 'ProductsView',
    TestViewTwo: 'TestViewTwo'
}

}

I have the routes:

routes: {
    '': 'home',
    'home' : 'home',
    'login' : 'login',
    'products' : 'products',
    'products/:id': 'product',
    'testingtwo' : 'testingtwo'
}

And, when the user gets on a certain route, I do the following check:

see if the view exists, if not create it, and add it to the viewport

home: function () {

    console.log('TestApp.controller.Router home function');

    var comp = this.getHomeView();

    // How can I get the view name from "comp", to avoid manually typing the name of the new view:
    newView = 'TestApp.view.HomeView';  // i want to avoid this.

    // the pseudo code should be:
    newView = comp.getViewName;


    if (comp === undefined) comp = Ext.create(newView);

    this.changeView(comp);
}

How can I get the view name from "comp", to avoid manually typing the name of the new view?

I have explained it better in the code above.

Any ideas?

有帮助吗?

解决方案

Use Ext.ClassManager.getClass(component);

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top