Forum /
Sencha Touch 2.x Forums /
Sencha Touch 2.x: Q&A /
Unanswered: How to switch/change views in sencha touch without destroying existing view
Unanswered: How to switch/change views in sencha touch without destroying existing view
I am using the below code to switch/change the view from one view to other view.
Ext.Viewport.remove(Ext.Viewport.getActiveItem());
var view = Ext.getCmp(viewId);
if(view) {
console.log("MainController: launchView - view present");
view.show();
}
else {
console.log("MainController: launchView - view not present");
view = Ext.create('VerticalComponentsBanking.view.'+viewName);
Ext.Viewport.setActiveItem(view);
}
Problem I am facing here is even though I am launching the same view multiple times using the above code is always execute the else part and prints "MainController: launchView - view not present" in the console.
Please let me know how to resolve this issue. Also let me know which is the efficient way to switch the views. Immediate response will be appreciated.
Thanks in advance.
Sencha - Senior Forum Manager
Use the setActiveItem method.
Just want to put my question in different way.
Ext.Viewport.remove(Ext.Viewport.getActiveItem());
Will the above line destroy the current view or it just removes from the view port??
Sencha - Senior Forum Manager
By default, it will destroy them.
There is a second parameter to this command. Try this:
Ext.Viewport.remove(Ext.Viewport.getActiveItem(), false);
Sencha is used by over two million developers. Join the community, wherever you’d like that community to be
or Join Us