1. #1
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default Answered: On Logout revert back to Viewport

    Answered: On Logout revert back to Viewport


    Hi,

    In my app i had a logout button. I want when a user tap on it, user must be redirect to viewport.

    In my app.js i had used
    launch: function() {
    Ext.create('Advait.view.Viewport');
    },

    For logout i had use below code in view
    {
    xtype: 'button',
    docked: 'bottom',
    ui: 'decline',
    style: 'border-radius:0',
    text: 'Logout',
    action: 'logoutuser'
    }

    and a logout function in my controller
    logout: function() {
    console.log('User will Logout');
    //What should i add here which will reload my vieport again
    }

    I am getting console.log message successfully. Please tell me which method will take me to viewport again.

    Thanks

  2. Hmm...this is strange.
    What version of Sencha Touch are you using?

    I created a quick SenchaFiddle to simulate your app structure. Maybe you can have a look at this and compare it to your code. I hope my example does exactly this what you want to achieve? It definitely works
    Here's the link: http://www.senchafiddle.com/#O9nRv

    Best regards,
    Schildi

  3. #2
    Sencha User
    Join Date
    Mar 2011
    Posts
    83
    Answers
    16
    Vote Rating
    11
    Schildi will become famous soon enough

      0  

    Default


    Hi deepakgarg89,

    I think the solution is like I said in your other thread...
    http://www.sencha.com/forum/showthre...sencha-touch-2

    You have to consider the Ext.Viewport as that component, which is responsible for showing the currently active view of all the views you have in your app, e.g. sth. like LoginForm, MainMenu, Imprint, DetailView etc. And this currently active view you can change with Ext.Viewport.setActiveItem(viewToShow);

    So lets suppose your user is not logged in at launch of your app, so you show the LoginForm-view:
    Code:
    var loginForm = Ext.create('MyApp.view.LoginForm');
    Ext.Viewport.setActiveItem(loginForm);
    When login is successful, you show the MainMenu-view:
    Code:
    var mainMenu = Ext.create('MyApp.view.MainMenu');
    Ext.Viewport.setActiveItem(mainMenu);
    And when the user logs out, to answer the question you asked above, you could send him back to the LoginForm again:
    Code:
    logout: function() {
        console.log('User will Logout');
    
        //What should i add here which will reload my vieport again
        var loginForm= Ext.create('MyApp.view.LoginForm');
        Ext.Viewport.setActiveItem(loginForm);  
    }
    So you don't have to "reload" your viewport, you just have to set the active item on it...

    Hope this helps

    Best regards,
    Schildi

  4. #3
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default Thanks for reply,

    Thanks for reply,


    As you suggested i had already used setActive viewport.

    My code is
    var loginstep = Ext.create('MyApp.view.Login');
    Ext.Viewport.setActiveItem(loginstep);

    But using this in cosole i am getting this error

    [DEPRECATE][MyApp.view.Login#show] Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component);

    Please tell me what should i do here.

  5. #4
    Sencha User
    Join Date
    Mar 2011
    Posts
    83
    Answers
    16
    Vote Rating
    11
    Schildi will become famous soon enough

      0  

    Default


    Ah, okay, I think you have to add your view you want to show to the viewport first, before you can navigate to it.
    Try
    Code:
    var loginstep = Ext.create('MyApp.view.Login');
    Ext.Viewport.add(loginstep);
    Ext.Viewport.setActiveItem(loginstep);
    Best regards,
    Schildi

  6. #5
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default Hi,

    Hi,


    I had already tried this code but again i am getting same error.

    My app hirearchy is Home->Login->List with logout button.

    Using below code i am successfully redirecting to Home view.
    var loginstep = Ext.create('MyApp.view.Home');
    Ext.Viewport.setActiveItem(loginstep);

    But when i again want to go to Login step than i am getting above discussed error

  7. #6
    Sencha User
    Join Date
    Mar 2011
    Posts
    83
    Answers
    16
    Vote Rating
    11
    Schildi will become famous soon enough

      0  

    Default


    In general you can say that every component has to be added to the Ext.Viewport before you show it.
    So maybe there's a different component than the Login-view, that you show but that is not added at this point of time?

    Or are you destroying any of your components anywhere? Something like Ext.getCmp('...').destroy()?
    Because then you also would remove the component from the viewport and have to add it again before it is shown.

    Best regards,
    Schildi

  8. #7
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default Hi,

    Hi,


    I was thinking the same but i had not destroyed any component. That's why it become confusing that the application is not loading.

  9. #8
    Sencha User
    Join Date
    May 2012
    Posts
    57
    Vote Rating
    0
    vikramiyer is on a distinguished road

      0  

    Default


    Any solutions that you have found so far??

  10. #9
    Sencha User deepakgarg89's Avatar
    Join Date
    Nov 2012
    Location
    Gurgaon, India
    Posts
    43
    Answers
    4
    Vote Rating
    0
    deepakgarg89 is on a distinguished road

      0  

    Default No, I didn't get any solution.

    No, I didn't get any solution.


    Still finding the answer

  11. #10
    Sencha User
    Join Date
    Mar 2011
    Posts
    83
    Answers
    16
    Vote Rating
    11
    Schildi will become famous soon enough

      0  

    Default


    Could you show more parts of your code, that causes this warning? That would be helpful I think

    Best regards,
    Schildi

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi