1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    5
    Vote Rating
    0
    nagasingari is on a distinguished road

      0  

    Default 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.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Use the setActiveItem method.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    5
    Vote Rating
    0
    nagasingari is on a distinguished road

      0  

    Default


    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??

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    By default, it will destroy them.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Sep 2012
    Posts
    7
    Vote Rating
    0
    Answers
    1
    imbailey is on a distinguished road

      0  

    Default


    There is a second parameter to this command. Try this:

    Ext.Viewport.remove(Ext.Viewport.getActiveItem(), false);