Note that there are some explanatory texts on larger screens.

plurals
  1. POMeteor: Preserving ClassName Flags
    text
    copied!<p>I'm having trouble using the preserve method in meteor. It doesn't seem to do what I want it to do. </p> <p>Basically, I have three nested templates which, when rendered, look something like this in their <strong>closed state</strong>:</p> <pre><code>&lt;div class="Dropdown"&gt;&lt;!--From Template1--&gt; &lt;div class="Group"&gt;&lt;!--From Template2--&gt; &lt;div class="SubGroup"&gt;&lt;!--From Template3--&gt; I'm the subgroup's content! &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>To view the content in the .SubGroup node, all template wrappers need to bear the .Open class name. This is done on a click event. Here's what it looks like in <strong>open state</strong>:</p> <pre><code>&lt;div class="Dropdown Open"&gt;&lt;!--From Template1--&gt; &lt;div class="Group Open"&gt;&lt;!--From Template2--&gt; &lt;div class="SubGroup Open"&gt;&lt;!--From Template3--&gt; I'm the subgroup's content! &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The issue is, when events fire and alter the database from within .SubGroup's content, it looks like <strong>Template2 and Template3 both get re-rendered and lose their programmatically applied .Open class</strong>. </p> <p>I've tried using <code>Template.Template2.preserve(['.Group']); </code> on each template with just about every selector I think could affect it. I've also tried {{#constant}} and {{#isolated}} helpers, but have yet to get expected results with these.</p> <p><strong>What's the right way to keep Meteor from wiping my class names out?</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload