Created
December 29, 2017 15:15
-
-
Save ralfbecher/ae80bd266087d82bd69b4358428d9216 to your computer and use it in GitHub Desktop.
Qlik Sense Mashup bind Enigma before openApp() is called
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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