1 Reply Latest reply on Nov 13, 2013 4:35 AM by Brethener

    Observer:SelectableChildProvider on tabnavigator trouble when close tab

    MrKoinkoin Level 1

      Hi,

       

      I've got a tabNavigator wired with SelectableChildProvider component which bind my PM's "tabs collection" in order to reflect new tab to be displayed/tab's updates/tab to be closed by updating the "tabs collection" thru the PM.

       

      Each tab owns its Context (created dynamically) in order to be able to dispatch event thrue tabs children targetted (no tabs interraction by catching event comming from other tabs).

       

       

      Everything seems to work fine : new entry in the arraycollection thru my PM is OK but the trouble comes when I close a tab other than the lastest one :

      Imagine I've got

      - Tab1 owning a context Ctx1 where there's defined PM1 used by inner children of Tab1

      - Tab2 owning a context Ctx2 where there's defined PM2 used by inner children of Tab2

      - Tab3 owning a context Ctx3 where there's defined PM3 used by inner children of Tab3

       

      In the MXML where is defined my tabnavigator and my observer I set tabNavigator's property like that tabClose="{model.removeTab(event)}" where model is the PM linked to the component which owns my tabnavigator and Observer.

       

      In this PM I've defined the removeTab event like this :

       

      public function removeTab(event:SuperTabEvent):void {

           event.preventDefault(); //prevent tabnavigator to deal with child to remove

           tabs.removeItemAt( event.tabIndex ); //update the tabs arraycollection -> will call Observer to change the tabnavigator content

      }

       

      In this way closing the tab2 will affect PM2 to tab3 exactly as if the tabs where only "shift" and the selected Object binded again.

      To be clear : The selected Object (a VO) is rightly set (eg: tab2 now owns VO from 3) but the PM the "tab" should refer is not PM3 but PM2 !!!

      This means that if my PM contains some business method to check/select variable binded from the view this view will show the ones from PM2 and not PM3...

       

      The new situation after tabs2 closed :

      - Tab1 owning  PM1 used by inner children of Tab1

      - Tab3(in fact the second tab but it may not be the tab3...) owning  PM2 used by inner children of Tab3

       

       

      If I remove the event.preventDefault() line the behaviour is OK but when I add an other tab the previously closed one appears again (the arrayCollection was not set correctly by the closeTab event.

       

      I've tried several things to solve the problem but it seems it cannot be fixed easily...

       

      Could you please help me with that ?

       

      Thx