2 Replies Latest reply: Feb 8, 2017 11:17 AM by Alexandre Depouez RSS

    Split Javascript function

    Alexandre Depouez

      Hi,

       

      I would like to split my javascript extension into function.

       

      Currently I have my extension defined like this:

       

      Qva.LoadScript(template_path + 'tinydropdown.js', function () {

          Qva.AddDocumentExtension('dropdownMenu', function(){

        Qva.LoadCSS(template_path + "tinydropdown.css");

       

        var _this = this;

        var mydoc = Qv.GetCurrentDocument();

       

        _this.Document.SetTabrowPaint(paintNav);

        var tabrowDiv = document.getElementById("Tabrow");

        tabrowDiv.removeAttribute("class");

        });

      });

       

       

      I would like to externalize these lines into a function:

        _this.Document.SetTabrowPaint(paintNav);

        var tabrowDiv = document.getElementById("Tabrow");

        tabrowDiv.removeAttribute("class");


      I have tried but it is not working.


      Could you please help me?

       

      Thanks

        • Re: Split Javascript function
          Adam Davies

          Hi Alexandre,

           

          Can you share what you did to try and do this?

           

          It should work fine as long as you're calling it etc

            • Re: Split Javascript function
              Alexandre Depouez

              Hi,

               

              I have tried to split te function like this:

               

               

              Qva.LoadScript(template_path + 'tinydropdown.js', function () {

                  Qva.AddDocumentExtension('dropdownMenu', function(){

                //Load a CSS style sheet

                Qva.LoadCSS(template_path + "tinydropdown.css");

              chargemenu();

              });

              });

               

              function chargemenu()

              {

                var _this = this;

                var mydoc = Qv.GetCurrentDocument();

                _this.Document.SetTabrowPaint(paintNav);

                // overrule the standard QlikView tabrow style

                var tabrowDiv = document.getElementById("Tabrow");

                tabrowDiv.removeAttribute("class");

              }