Skip to content

Instantly share code, notes, and snippets.

@ralfbecher
Created December 29, 2017 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralfbecher/ae80bd266087d82bd69b4358428d9216 to your computer and use it in GitHub Desktop.
Save ralfbecher/ae80bd266087d82bd69b4358428d9216 to your computer and use it in GitHub Desktop.
Qlik Sense Mashup bind Enigma before openApp() is called
//
// Bind Enigma before openApp() is called
//
var prefix = window.location.pathname.substr(0, window.location.pathname.toLowerCase().lastIndexOf("/extensions") + 1);
var config = {
host: window.location.hostname,
prefix: prefix,
port: window.location.port,
isSecure: window.location.protocol === "https:"
};
require.config({
baseUrl: (config.isSecure ? "https://" : "http://") + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"
});
require(["js/qlik", "jquery"], function (qlik, $) {
qlik.setOnError(function (error) {
alert(error.message);
});
var global = qlik.getGlobal();
var scope = $('body').scope();
scope.enigma = null;
var unbind = scope.$watch(function() { return global.session.__enigmaApp }, function (newValue, oldValue) {
if (newValue) {
scope.enigma = newValue;
console.log("bound Enigma", scope.enigma);
unbind();
// call rest of script
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment