I'm able to embed a Tableau dashboard into my HTML using the raw embed code, but now I want to be able to save that embed code as a variable so that it can be linked with a dropdown menu and toggle on/off. Here's the embed code:
And here is my attempt to stringify at and save it as a JavaScript variable:
var myEmbedCode= '
'When I try to call the variable with an event listener, it doesn't work and the dashboard is not rendered.
$(document).ready(function(){
$('#tableauToggle').on('click', function(e) {
// Prevent the page from reloading
document.getElementById("tableauContent").innerHTML = myEmbedCode
});