Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your problem is not related to Knockout or to the <code>if</code> contenerless binding but Durandal.js (which is used by the HotTowel templates) and how Durandal handles the view model.</p> <p>Because in Durandal.js your <strong>viewmodel should only contain one root element</strong> and it removes the root level comments. </p> <p>From the <a href="http://durandaljs.com/documentation/Creating-A-View/">documentation</a>:</p> <blockquote> <p>The view has exactly one root element. Durandal requires this. <em>If comments are found at the root, they will be removed.</em> In the case where more than one root element is found, they will be wrapped in a div.</p> </blockquote> <p>So the solution is simple: just more the two text inside the <code>section</code> or wrap everything into a <code>div</code> or <code>section</code>:</p> <pre><code>&lt;section&gt; &lt;h2 class="page-title" data-bind="text: title"&gt;&lt;/h2&gt; &lt;!-- ko if: active()==true --&gt; hiiiiiiiiiiiiiii &lt;!--/ko--&gt; &lt;div data-bind="visible: active() == true"&gt; byeeeeeeeeeeeee &lt;/div&gt; &lt;/section&gt; </code></pre> <p>Or</p> <pre><code>&lt;div&gt; &lt;section&gt; &lt;h2 class="page-title" data-bind="text: title"&gt;&lt;/h2&gt; &lt;/section&gt; &lt;!-- ko if: active()==true --&gt; hiiiiiiiiiiiiiii &lt;!--/ko--&gt; &lt;div data-bind="visible: active() == true"&gt; byeeeeeeeeeeeee &lt;/div&gt; &lt;/div&gt; </code></pre> <p>By the way instead of <code>if: active()==true</code> and <code>visible: active() == true</code> you can simple write: <code>if: active</code> and <code>visible: active</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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