user2399430
user2399430

Reputation: 13

Meteor {{currentUser}} and rendering

I have been trying to resolve an issue for awhile with rendering of content and the {{currentUser}} check in meteor. A code snippet is below:

    {{#if currentUser}}
    <div class="sparkline-box side">

      <div class="sparkline-row">
        <h4 class="gray"><span>Pending Contract Actions</span> 25</h4>
        <div class="sparkline big" data-color="gray"><!--28,11,24,24,8,20,26,22,16,6,12,15--></div>
      </div>


      <hr class="divider">
      <div class="sparkline-row">
        <h4 class="dark-green"><span>Outstanding Task Orders</span> $43.33M</h4>
        <div class="sparkline big" data-color="darkGreen"><!--16,20,6,19,25,22,9,13,7,10,15,4--></div>
      </div>

      <hr class="divider">
      <div class="sparkline-row">
        <h4 class="blue"><span>Current Month Actions</span> 45</h4>
        <div class="sparkline big" data-color="blue"><!--20,18,21,17,5,7,29,9,8,14,23,8--></div>
      </div>

      <hr class="divider">

  </div>
  {{/if}}

With the {{currentUser}} block in place, the text appears, but the sparkline charts do not render in the browser, even when the page is reloaded. If I am not logged in, the text and charts are not visible. The problem is with the rendering of the sparkline charts when wrapped in the {{currentUser}} block. This also happens with other third-party javascript libraries that I am using in the application if wrapped in a {{currentUser}} block. Any thoughts on what may be happening?

Thanks!!

Upvotes: 1

Views: 1211

Answers (1)

Xyand
Xyand

Reputation: 4488

What happens is that meteor re-renders the context when {{currentUser}} changes. It does not preserve any changes made to the DOM by third parties. Read about isolate, preserve and constant. I believe that {{#constant}} will do the trick here.

Upvotes: 1

Related Questions