Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A simple way to debounce in a paint() function of a classic (non-angular) QlikSense extension
define([
"jquery",
"qlik",
"underscore"
],
function ($, qlik, _) {
'use strict';
return {
initialProperties: {},
definition: {},
paint: function ($element, layout) {
var that = this;
if (!$element.scope().$parent.hasOwnProperty("renderFn")) {
$element.scope().$parent.renderFn = _.debounce(renderMe, 400, true);
}
// THE RENDER FUNCTION (my paint fn)
function renderMe($element, layout, this) {
// .. just do it
}
function isEditMode() {
if (qlik.navigation.getMode() === "analysis") {
return false;
} else {
return true;
}
}
// yea, magic happens here..
if (isEditMode() || layout.qSelectionInfo.qInSelections) {
renderMe($element, layout, _context);
} else {
$element.scope().$parent.renderFn($element, layout, _context);
}
// tbc
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.