Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ralfbecher/e83b437d925dcf9996d82e5d5db569a9 to your computer and use it in GitHub Desktop.
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