4 Replies Latest reply on Nov 4, 2011 3:04 AM by Jakoub2

    Disable click on the second tab

    Jakoub2

      Hi, I created mobile app with some Views (tabs). On first View (first tab)I have required text fiels.  I would like
      disable click on second view (second tab) - enable false?? - , if this text fiels will be empty.
      How I can do it? I created in header on first tab function

      focusOut="view1_focusOutHandler(event)">

      and there  I put my code for validating text fiels. If false, I call function

      navigator.pushView(myFirstTab);

      but it isn't ok, I can see second tab and after screen move on first view.
      Can anybody say me, how I can do it better?
      Regards

        • 1. Re: Disable click on the second tab
          Jason Szeto Level 3

          You can toggle the enabled property of the second ViewNavigator. Setting it to false will make the tab disabled.

          • 2. Re: Disable click on the second tab
            Jakoub2 Level 1

            Hi Jason,

             

            thank you for your help me, but I didn't find, how I can obtain access from first tab to the second tab.

             

            If I tryed mySecondTab + dot  , I didn't see enable property, if  I tryed

             

            var mySecondTab:MySecondTab = new MySecondTab();

            mySecondTab.enable = false;

             

             

            this code works fine, but without any result in my live tab (it is ok, I created new instance of my tab, it doesn't work with my  "live" tab).

             

            Next I tryed obtain object from

             

            navigator.getChildByName("mySecondTab");

               //name mySecondTab is a name in id properties

             

            or

             

            navigator.getChildByName("MySecondTab");

             

            //name MySecondTab is a name of component in a project

             

             

            but both function returns null.

             

            Thank you

            • 3. Re: Disable click on the second tab
              Jason Szeto Level 3

              This was my hacky way of getting to the second ViewNavigator

               

              In my View:

              var navTwo:ViewNavigator = TabbedViewNavigatorApplication(FlexGlobals.topLevelApplication).navigators[1] as ViewNavigator;

              navTwo.enabled = !navTwo.enabled;

               

               

              <s:navigators>
                  <s:ViewNavigator id="navOne" label="One" firstView="views.SecondView"/>
                  <s:ViewNavigator id="navTwo" label="Two" firstView="views.SPUCHomeView" enabled="false"/>
              </s:navigators>
              • 4. Re: Disable click on the second tab
                Jakoub2 Level 1

                Hi, thank you for your code. It works perfect.