0 Replies Latest reply: Feb 10, 2015 12:44 AM by Bob Slattery RSS

    Load HTML snippet into Extension Object

      I'm trying to work more efficiently and test my extension object in a browser before bringing it into QV.

      To do this, I need to have a stand-alone HTML to test on the browser.  To avoid duplication, I want to import the relevant section of the stand-alone HTML into the QV extension object.

      I attempted to do it as follows...

      1. Add empty container during document load
        $('div[title="extension"] ~ .QvContent').append("<div id='container'></div>");
      2. Use the jQuery load method to import the relevant section of the stand-alone HTML doc
        $("#container").load(template_path + "extension.html #snippet"

      The problem I have is how to get the correct URL to address the HTML file which is on my local hard drive.

      I tried

      1. absolute referencing from the root of my C drive
      2. the same reference that Qv uses for loading extension object components
        Qva.Remote + "?public=only&name=Extensions/CB/extension/"
      3. moving the source HTML doc to the Program Files\QlikView folder

       

      None of these attempts have worked, can anyone advise if this is possible?

       

      Sample code...

       

      var template_path = Qva.Remote + "?public=only&name=Extensions/CB/extension/";

      function extension_Init() {

          // Use QlikView's method of loading other files needed by an extension.

          // These files should be added to your extension .zip file (.qar)

          if (typeof jQuery == 'undefined') {

              console.log('Loading jQuery...')

              Qva.LoadScript(template_path + 'jquery.js', extension_Done);

          }

          else {

              console.log('jQuery already loaded...')

              extension_Done();

          }

      }

       

       

      function extension_Done() {

          //Add extension

          Qva.AddExtension('CB/extension', function () {

              //Load a CSS style sheet

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

              var _this = this;

              //Add empty container

              $('div[title="extension"] ~ .QvContent').append("<div id='container'></div>");

       

       

              //execute after doc loaded

              $(document).ready(function () {

                  console.log('trying to load from ' + template_path);

                  $("#container").load(template_path + "extension.html #snippet",

                      function (response, status, xhr) {

                          var msg = 'body loaded status :';

                          if (status == 'error') {

                              console.error(msg + xhr.status + " " + xhr.statusText)

                          } else {

                              console.log(msg + 'Succsess')

                          }

                          console.log(msg + 'Complete')

                      })

              })

          });

      }

      //Initiate extension

      extension_Init();