6 Replies Latest reply on Mar 9, 2012 11:22 AM by saisri2k2

    Reload each tab in TabNavigator on selection

    rjoshicool Level 2

      I have some views in my TabNavigator container. I need to load all these each time a tab is selected so that the creationComplete fires each time. Or is there an event which I can use to make everything load again when the view is selected?

        • 1. Re: Reload each tab in TabNavigator on selection
          jfb00 Level 3

          HI,

          You can use creationPolicy="all" on the tab navigator to load all.

          Or you can create deferred component later:

          http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7aee.html

          HTH,

          • 2. Re: Reload each tab in TabNavigator on selection
            rjoshicool Level 2

            But in this will it create the tab each time it is visited? If I have 3 tabs say: Home, About and Contact, I want that creationComplete of Home should be fired each time it is clicked.

            • 3. Re: Reload each tab in TabNavigator on selection
              jfb00 Level 3

              You want to reload Home every time is click?

              What do you have there? Do you want to refresh data?

              Share some code and explain more, we cannot guest.

              Best,

              • 4. Re: Reload each tab in TabNavigator on selection
                rjoshicool Level 2

                Here is an excerpt from the code I am using:

                 

                <s:NavigatorContent width="100%" height="100%"
                                              label="Manage Accounts">
                                                        <mx:TabNavigator width="100%" height="100%"
                                                                                                 top="10">
                                                                  <s:NavigatorContent width="100%" height="100%" label="Manage">
                                                                            <Tabs:ManageAccountsManage />
                                                                  </s:NavigatorContent>
                                                                  <s:NavigatorContent width="100%" height="100%" label="Create">
                                                                            <Tabs:CreateAccount />
                                                                  </s:NavigatorContent>
                                                        </mx:TabNavigator>
                </s:NavigatorContent>
                

                 

                 

                Here I have 2 tabs, Manage and Create. Create creates an account which loads some data from Web. I want that whenver the Create Tab is clicked, user gets to see the content in the page refreshes and the user gets latest data from the Web.

                • 5. Re: Reload each tab in TabNavigator on selection
                  jfb00 Level 3

                  You have to add an event listener for the tab navigator at the time you form is load like:

                   

                  myTN.addEventListener(MouseEvent.CLICK, onTabClick, true);

                   

                  where myTN is the id of the tab navigator and onTabClick is the function will listen when user do the click.

                  Here is an example on how to check for the click:

                   

                  private function onTabClick(event:MouseEvent):void{

                                  if (event.target.label == "Create"){

                                      Alert.show("Refresh Data","Alert");

                                  }

                              }

                   

                  Example

                  http://www.roseindia.net/flex/add-event-listener.shtml

                   

                  HTH,

                  1 person found this helpful
                  • 6. Re: Reload each tab in TabNavigator on selection
                    saisri2k2 Level 4

                    Or you can listen of Hide or Show events and remove the child in the Navigator content and add it again.