Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need urgent help in Extensions Script

Hi

I have  a script which basically selects the listbox in qlikview using Qlikview Ajax API and its continously running in a loop .

function Demo () {

Qv.AddExtension("ET-HelloWorld",

        function () {

  var _this=this;

            // Set the extension object's inner Html

  var doc=Qv.GetCurrentDocument();

        this.Element.innerHTML = 'Save Selection';

  var lb;

  var jsFiles = [];

        jsFiles.push('Extensions/Objects/ET-HelloWorld/lib/js/jquery.js');

        Qv.LoadExtensionScripts(jsFiles, function () {

          

             

              

  initQlikView(doc);

 

            });

function initQlikView(doc)
{
doc.GetAllObjects(function(objects) {
for (var i = 0; i < objects.length; i++) {
if (objects.type == 'List Box' && objects.id.match(/LB15/)) {

                var object =doc.GetObject(objects.id,function(){object.Data.SelectTexts("GA")});

}
}});
}


The output i get is continue alert box . I think the SelectTexts function again triggers the execution of the entire script and ends up as unending loop of function calling itself

Any ideas how implement the code to avoid circular callback ?

1 Reply
organgrindingmo
Partner - Contributor III
Partner - Contributor III

I've run into the same problem and kinda solved it by doing this.

var attached = false; // <-- outside the closure so that is doesnt get set when extension re-renders

if(!attached) {

    attached = true;

    var obj = doc.GetObject("LB02");

    obj.callbackFn = function() {

       var arr = ["TextValue"];

       this.Data.SelectTexts(arr);

       this.callbackFn = null;

       }

}

It's not very elegant but seems to be working.