Created
May 9, 2017 21:53
Star
You must be signed in to star a gist
A simple way to debounce in a paint() function of a classic (non-angular) QlikSense extension
This file contains 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
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