1 Reply Latest reply on Nov 30, 2016 6:09 AM by lenaic.ridinger

    API - Respond to Events & Pass Single Value Only

    Stephen Hellyar

      Hi,

       

      This is what I want to do  {{ entry.name }}.   I want "name" to be passed from the selected mark.  So it looks like this.   {{ entry.nameOfSelectedMark }}

       

      So far, I used the Respond to Events tutorial here to get the basic functionality working.   But now I want to  get the reportSelectedMarks function to print just the value of the name field for the selected mark.  The dimension's name is Program Name.

       

       

        <script type="text/javascript"> var viz;  function initViz() { var containerDiv = document.getElementById("vizContainer"), url = "http://public.tableau.com/views/RegionalSampleWorkbook/College", options = { "Academic Year": "", hideTabs: true, onFirstInteractive: function () { listenToMarksSelection(); } }; viz = new tableau.Viz(containerDiv, url, options); }  function listenToMarksSelection() { viz.addEventListener(tableau.TableauEventName.MARKS_SELECTION, onMarksSelection); }  function onMarksSelection(marksEvent) { return marksEvent.getMarksAsync().then(reportSelectedMarks); }  function reportSelectedMarks(marks) { var html = ""for (var markIndex = 0; markIndex < marks.length; markIndex++) { var pairs = marks[markIndex].getPairs(); html += "<b>Mark " + markIndex + ":</b><ul>"for (var pairIndex = 0; pairIndex < pairs.length; pairIndex++) { var pair = pairs[pairIndex]; html += "<li><b>Field Name:</b> " + pair.fieldName; html += "<br/><b>Value:</b> " + pair.formattedValue + "</li>"; } html += "</ul>"; }  var infoDiv = document.getElementById('markDetails'); infoDiv.innerHTML = html; } </script>

       

       

      And yes, I did replace the url with the url of my dashboard.

       

      Thanks.