1. #1
    Touch Premium Member hotdp's Avatar
    Join Date
    Nov 2010
    Location
    Denmark
    Posts
    603
    Vote Rating
    14
    hotdp will become famous soon enough

      0  

    Question Cleaning up items in Card layout

    Cleaning up items in Card layout


    Hey,
    In ST1 I used:
    Code:
    cardswitch: function(thisPanel, newCard, oldCard) {
    if (oldCard) {
                    if (thePanel.items.indexOf(oldCard) > thePanel.items.indexOf(newCard)) {
                        this.remove(oldCard, true);
                    }
                }
        },
    So everytime I put a new Card in the container nothing happend but if I went back it would delete the old card. By doing so the number of items stayed small.

    I am trying to do the same thing in ST2 without any luck:
    Code:
    onSearchContainerActiveItemChange: function(container, value, oldValue, options) {
            if(oldValue){
                if (container.items.indexOf(oldValue) > container.items.indexOf(value)) {
                    container.remove(oldValue, true);
                }
            }
        }
    Is ActiveItemChange run before or after the item is changed?
    What am I doing wrong? And how can I solve this issue.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,633
    Vote Rating
    817
    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


    The activeitemchange event should fire after the activeitem has been changed but you may run into issues with the animation.
    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.

  3. #3
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    548
    Vote Rating
    18
    estesbubba will become famous soon enough

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    The activeitemchange event should fire after the activeitem has been changed but you may run into issues with the animation.
    Believe we ran into the animation problem and used Ext.defer to remove the item. This allowed the animation to complete before removing the card. I don't have the code any more as we are using NavigationView which now auto destroys on pop. It used to not do that so we listened to activeitemchange.

  4. #4
    Touch Premium Member hotdp's Avatar
    Join Date
    Nov 2010
    Location
    Denmark
    Posts
    603
    Vote Rating
    14
    hotdp will become famous soon enough

      0  

    Default


    Quote Originally Posted by estesbubba View Post
    Believe we ran into the animation problem and used Ext.defer to remove the item. This allowed the animation to complete before removing the card. I don't have the code any more as we are using NavigationView which now auto destroys on pop. It used to not do that so we listened to activeitemchange.
    Oh my, I would love to have that code...

    When I use RemoveAt I get animation problems. When I use Remove I get Stack problems.

    Would love to use the Navigation View but my problems is that I have different buttons in the Toolbar on the different Views. As I see it I can't add buttons to the Navigation View Toolbar.

    @mitchellsimoens What is the best way to solve this problem and keeping the number of items in the Card layout small?

  5. #5
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    548
    Vote Rating
    18
    estesbubba will become famous soon enough

      0  

    Default


    Found the code when we would remove old view from NavigationView. NavigationView is just a container with card layout and convenience functions. You can add your own items to the toolbar by view.getNavigationBar().

    Code:
        onPop: function(container, view, opts) {
            Ext.defer(container.remove, 100, this, [view]);
        }

  6. #6
    Touch Premium Member hotdp's Avatar
    Join Date
    Nov 2010
    Location
    Denmark
    Posts
    603
    Vote Rating
    14
    hotdp will become famous soon enough

      0  

    Default


    Quote Originally Posted by estesbubba View Post
    Found the code when we would remove old view from NavigationView. NavigationView is just a container with card layout and convenience functions. You can add your own items to the toolbar by view.getNavigationBar().

    Code:
        onPop: function(container, view, opts) {
            Ext.defer(container.remove, 100, this, [view]);
        }
    Does pop not normally destroy the item? Or are there also gettig more and more items there?

  7. #7
    Ext JS Premium Member
    Join Date
    Apr 2010
    Location
    Omaha, NE
    Posts
    548
    Vote Rating
    18
    estesbubba will become famous soon enough

      0  

    Default


    autoDestroy is true for navview so pop should destroy.

  8. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,633
    Vote Rating
    817
    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


    Deferring a certain amount of milliseconds helps a lot. I usually do a couple hundred as it lets the DOM settle down a little form the animation but quick enough before the user can start interacting.
    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.