5 Replies Latest reply on Mar 15, 2017 5:08 AM by Mark McCracken

    After 10.0.2 upgrade on Tableau Online addEventListener not working

    Chris Reynolds

      I am registering several events for several Vis objects on a single page.  (See code below)

       

      When I click on the Vis in 10.0.1 the code worked fine, however now it is no working after upgrade to 10.0.2.

       

      --- Code ------

       

      /*

        Build all needed events

        */

        function enableEvents(viz){

        //Add an Event Listener for a click on a mark. 

        viz.addEventListener("marksSelection", function(marks) {

        console.log("Mark selection captured");

        console.log(marks);

        onMarksSelection(marks);

        });

        // Add an Event listener for a filter change

        // This is currently only logged as filters are controled by parameters so no actions here. This is for logging only.

        console.log("Registering Event Listeners")

        viz.addEventListener("filterchange",function(filter) {

        console.log("Filter change captured");

        console.log(filter);

        });

       

        // Add an Event Listener for a parameter value change.  This is how we are changing filters for time and GEO

        viz.addEventListener('parametervaluechange', function(event) {

                console.log(event);

       

                // Get viz attached to the event and identify what parameters are set on Viz

        event.getViz().getWorkbook().getParametersAsync().then(function(parameter){

        // search all parameters for "DateRangeParam" as there can be more then one param in viz save the DateRangeFilter param to

        // currentDateRangeFilter varable and update all Vizs with this new value

        for(var i=0;i<parameter.length;i++) {

        if(parameter[i].getName().indexOf("DateRangeParam")>=0) {

        currentDateRangeFilter = parameter[i].getCurrentValue().formattedValue+'' //set global DateRangeParam for future changes

        // loop through all current vizs and apply param change

        for(var a=0;a<currentVizs.length;a++){

        var strValue=parameter[i].getCurrentValue().formattedValue+'';

        currentVizs[a].getWorkbook().changeParameterValueAsync(parameter[i].getName().toString(),currentDateRangeFilter).otherwise(function(err) { console.log(err);});

        console.log("applied setting: "+parameter[i].getName()+" "+currentDateRangeFilter);

        }

        }

        }

        })

                console.log("PARAMETER CHANGE captured");

            });

       

        }