4 Replies Latest reply on Nov 2, 2017 10:54 AM by Joydeep Chakraborty

    ButtonBar in EB 1.7

    Martin Sramo

      Hi all, I am playing a little bit with a new feature in Enterprise Browser 1.7 -> Custom ButtonBars. I defined some layouts for the bars and I tried the custom JavaScripts for the buttons as well. Everything I tried worked fine for me until now.

      Today I wanted to create a button on the page to show/hide (toggle) the ButtonBar1 and ButtonBar2. So according to TechDocs I wrote a script right in the HEAD section of the html page with the following code:

       

      var barOpened = 0;
              function toggleBar()
              {
                  if (barOpened == 0){
                      showBar();
                  } else {
                      hideBar();
                  }
              }
              
              function showBar()
              {
              barOpened = 1;
              ButtonBar1.show();
              ButtonBar2.show();
              }
      
              function hideBar()
              {
              barOpened = 0;
              ButtonBar1.hide();
              ButtonBar2.hide();        
              }
      

       

      and I added a button on the page:

       

      <button align="center" onclick="toggleBar()">Toggle button bar</button> 
      

       

      Unfortunately, it does not work. When I press the button, ButtonBars don't show/hide as wanted. I debugged the code using Chrome DevTools and it throws an error for ButtonBar1:

      Uncaught ReferenceError: ButtonBar1 is not defined

      So I tried to use customDOM injection method I used before to show the bars and this works fine.

      <meta http-equiv="ButtonBar1" content="Visibility:Visible" pages='*'/>
      <meta http-equiv="ButtonBar2" content="Visibility:Visible" pages='*'/>
      

       

      But even if I show the Button bars this way, my Toggle button still does not work.

       

      I tried to read the TechDocs articles related to ButtonBar API several times, but I wasn't able to solve this issue. I guess I'm just missing little-something-somewhere, as usually

       

      Anyone have an idea what could be the problem?

       

      Martin

        • Re: ButtonBar in EB 1.7
          Joydeep Chakraborty

          Hi Martin,

          1.Have you added elements.js in your page?

          2.Can you please try buttonBar1.show() in ButtonBar1.show()?

           

          If not resolved please share the page. Will make it work.

           

          Regards,

          Joydeep

            • Re: ButtonBar in EB 1.7
              Martin Sramo

              Hi Joydeep,

              1. while I think it's not obvious for the newcomers, I somehow put strings together and after I noticed that ButtonBar API is referenced under RhoElements APIs, I added the elements.js, but using DOM injection Right now, I'm thinking if this could be the issue, because the script in html page is loaded first, before elements.js are loaded using DOM injection. I can test it again on monday by loading elements.js right in the html page and I will let you know.

              2. I already tried with lowercase and uppercase, there was no difference. In button.xml file, I have ButtonBar1 and ButtonBar2.

               

              Thanks for the idea.

               

              Regards,

              Martin