1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    22
    Vote Rating
    0
    Answers
    1
    Kapoc is on a distinguished road

      0  

    Default Answered: Best practice to destroy views on pop()

    Answered: Best practice to destroy views on pop()


    Hello I was wondering what is the best practice to destroy views on pop from a navigationView

    i think listening for the pop event and then calling a function
    onPop: function(thisNav, view){
    thisNav.remove(view, true);
    }

    would work, but i am unsure if there is a recomended way of destroying views that get popped out of the navigationView

    thanks in advance for any tips

  2. as long as autoDestroy is true on the child items (which it is true by default) then when you pop or press the back button on the navigation view it will remove the item and therefore automatically destroying it.

  3. #2
    Sencha User
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    508
    Vote Rating
    74
    Answers
    25
    shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough shepsii is a jewel in the rough

      0  

    Default


    I'm very interested to learn the best practice here.

    I defer a function by a second which then destroys the view but I don't like this.

    Ideally they'd be an event that fires like "afterdeactivate" or something that we could use to destroy the view; currently deactivate fires at the start of the animation, when the view is still required - not at the end of the animation when the view has completely left the viewport.

  4. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,642
    Vote Rating
    899
    Answers
    3574
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    as long as autoDestroy is true on the child items (which it is true by default) then when you pop or press the back button on the navigation view it will remove the item and therefore automatically destroying it.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

  5. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    22
    Vote Rating
    0
    Answers
    1
    Kapoc is on a distinguished road

      0  

    Default


    thanks, i didn't know that remove was called automatically when a view is popped, so theres no need write an extra function for the pop event

  6. #5
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    Answers
    41
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    as long as autoDestroy is true on the child items (which it is true by default) then when you pop or press the back button on the navigation view it will remove the item and therefore automatically destroying it.
    Good to know that! Thanks.