Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Highlighted
Partner
Partner

Use external js-plugin in extension

I have an issue when trying to use a js-plugin (bootstrap-tour) inside my extension.

The way to initiate the js-plugin on a regular website would be like the following at it works fine:

var tour = new Tour({

  // Steps

]});

But when I import the plugin into the extension I'm not able to access the functionality in the same way.

define( [

        "qlik",

        "jquery",

        "text!./template.html",

        "./bootstrap-tour-standalone"

    ],

    function ( qlik, $, template, _bootstrapTour ) {

        return {

            template: template,

            support: {

                snapshot: true,

                export: true,

                exportData: false

            },

            paint: function ($element, layout) {

                return qlik.Promise.resolve();

            },

            controller: ['$scope', function ( $scope) {

                var tour = new Tour({

                  // Steps

                ]});

            }]

        };

    });

It throws the following error:

Skärmklipp.PNG

My guess is that it has something to do with this part of the code inside the plugin (I have remove a lot of code to give an easier overview):

(function(window, factory) {

  if (typeof define === 'function' && define.amd) {

    return define(['jquery'], function(jQuery) {

      return window.Tour = factory(jQuery);

    });

  } else if (typeof exports === 'object') {

    return module.exports = factory(require('jquery'));

  } else {

    return window.Tour = factory(window.jQuery);

  }

})(window, function($) {

  var Tour;

  Tour = (function() {

    function Tour(options) {}

    return Tour;

  })();

  return Tour;

});

Any idea what I need to do to be able to access the Tour object inside the plugin?


Regards

2 Replies
ErikWetterberg
Honored Contributor

Re: Use external js-plugin in extension

Have you tried:

define( [ 

        "qlik"

        "jquery"

        "text!./template.html"

        "./bootstrap-tour-standalone" 

    ],  function ( qlik, $, template, Tour ) { 


Erik Wetterberg

Partner
Partner

Re: Use external js-plugin in extension

Yes, unfortunately I have tried that. But it gives a new error.

Skärmklipp.PNG

It seems like functions are being executed before I actually calls the init()-function.

Because if I compare to the regular website, that piece of code on row 2348 is only being executed after I call the init()-function:

tour.init()