6 Replies Latest reply on Mar 14, 2019 10:52 PM by Eslam_Elbyaly

    Switch tabs on page load

    Eslam_Elbyaly

      Apex 18.2.

      I have a tab container(invoice) with two tabs(invoicehdr and invoicedtl). I want to make the invoicedtl tab active when the user runs the page. I am using this code to do so,

      $("#invoice .a-Tabs").aTabs("getTabs")
      ["#SR_invoicedtl"].makeActive();
      

       

      it throws,

      Uncaught TypeError: Cannot read property 'makeActive' of undefined

       

      Same code is working fine when used with a dynamic action on a button.

      What is wrong here?

        • 1. Re: Switch tabs on page load
          Franck N

          Hi,

          there is Many Way to do that. The Easier is to add a static ID to your Region like "tab_3" for Example

          then add  this code on When page Load:

            

          $("#tab_3_tab a").trigger("click");
          

           

          Working example:

          https://apex.oracle.com/pls/apex/f?p=23606:22:119306665349836:::::

           

          regards,

          Franck

          1 person found this helpful
          • 2. Re: Switch tabs on page load
            Eslam_Elbyaly

            my tab's static id is "invoicedtl". So I tried it like this,

            $("#invoicedtl_tab a").trigger("click"); 

            and it did not work.

            What is "_tab a"?

            • 3. Re: Switch tabs on page load
              Franck N

              Hi,

               

              i also tested it on on apex 18.2 which means it should also work for you also:

               

              where did you add the code:

              what are your regions settings?:

               

              .

              the "_tab" is getting added to your region_tab_id  each tab should have it´s own static ID so for you. this call should be ok.

              $("#invoicedtl_tab a").trigger("click");

              "a" is the html class for the reference you can observ it with your browser developper:

               

               

               

              in case you still have any issue , please provide a sample example on apex.oracle.com and i could have a look.

               

              Regards,

              Franck

              • 4. Re: Switch tabs on page load
                Eslam_Elbyaly

                I think we're doing it differently. I used to create a static content tab and change the template to "tab container" then add the sub regions to it. I tried your way and it worked but this is not the way I want to implement it. I do not want "Show All" tab.

                BTW: your way of activating tabs was critisized by John Synders in another thread and he provided the way I mentioned above to switch between tabs but I do not know why it is not working when page loads. Maybe the markup of the tab is not rendered yet.

                • 5. Re: Switch tabs on page load
                  Franck N

                  Hi,

                   

                   

                  I think we're doing it differently. I used to create a static content tab and change the template to "tab container" then add the sub regions to it. I tried your way and it worked but this is not the way I want to implement it. I do not want "Show All" tab.

                   

                  you can remove the "show all" while selecting  the "attributes" of your tab container  region and unselect it.

                   

                  BTW: your way of activating tabs was critisized by John Synders in another thread and he provided the way I mentioned above to switch between tabs but I do not know why it is not working when page loads. Maybe the markup of the tab is not rendered yet.

                  It was never meant to be used on page Load, only while interacting with another component .

                  BTW: you are not the first person facing this issue while trying to use that Query on page Load.

                   

                  What i provided is a work arround to the issue . If you find anything better feel free to use it and post the solution so that we can all make use of it.

                  1 person found this helpful
                  • 6. Re: Switch tabs on page load
                    Eslam_Elbyaly

                    I think John Snyders-Oracle is the only one who can help because it is not documented yet.