4 Replies Latest reply: Apr 6, 2018 7:46 AM by Hans Christian Riis RSS

    Selection API and Buttons?

    Hans Christian Riis

      Hi all

       

      I'm trying to use the Selection API to extract the current selected filter values, by adding a button to a mashup.

       

      Using the example code from https://help.qlik.com/en-US/sense-developer/September2017/Subsystems/APIs/Content/CapabilityAPIs/SelectionAPI/qlik-selec…

       

      require(["js/qlik"], function(qlik) { //open apps -- inserted here --  

      var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); 

      var selState = app.selectionState( );

      var listener = function() { alert('Back count:' + selState.backCount); selState.OnData.unbind( listener ); }; selState.OnData.bind( listener );


      I put it into a button and everything works fine on the first click. If i select value A, B, C in a filter and press, the desired values are returned. If i make a new selection, and press the button, nothing happens until i make another selection in the filter.


      $('.export_selections').on('click', function () {  })


      I assume it's something with the bind/unbind listener? It's probably a simple problem, but can't figure out where to look.