Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.