2 Replies Latest reply on Nov 29, 2016 8:35 AM by Richard Naylor

    best practice for clearing 'viz_container' prior to load

    Richard Naylor

      we are running our site via angularjs in a single page app. we are loading the viz into a div on the page using the standard set in the documentation:

         function initViz() {

           var containerDiv = document.getElementById("vizContainer"),

           url = "https://YOUR-SERVER/views/YOUR-VISUALIZATION"

           var viz = new tableau.Viz(containerDiv, url);

         }

       

      Frequently, we run into issues where there is already a value set in vizContainer and our filter queries wont work or we end up with 2 dashboards on our page. We are dealing with this in some ways i would describe as patchy. WOndering if anyone else out there is dealing with this 'elegantly'.

        • 1. Re: best practice for clearing 'viz_container' prior to load

          Hey Richard,

           

          Just a question, if you try embedding the viz into a fresh page does the issue still occur? My thinking is that if you had a pre-existing page with its own heavy footprint, there may be some existing code that is causing the issue.

           

          -Diego

          • 2. Re: best practice for clearing 'viz_container' prior to load
            Richard Naylor

            Hi Diego,

            Thx for responding, Ive been meaning to get back to this and add some of what I learned. We are using AngularJS 1 as our front end framework and viewing dashboards in a 'single page app' format. We moved into this in dev over the last month or so, and have been going through a real change in the way we think about web dev because of this format. Previously, a user would do a page load every time they went to a new dashboard, and as such, the 'viz' variable (referenced in the original post) used to load a dashboard would be initialized/reinitialized on each page load. Because of this, we never thought about having to evaluate whether or not 'viz' had a value already. So, to keep this from getting much longer, prior to loading up viz we just wrote code to evaluate whether or not it had anything in it, and if it did call 'viz.dispose()';

            Anyone referencing this can look up the 'dispose' function and its syntax in the api documentation.