Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamic composition using knockout and durandal doesn't work
    primarykey
    data
    text
    <p>I have a strange problem while using Durandal/Knockout. In some cases the binding doesn't work properly. I've simplified my situation which came in this question.</p> <p>I'm setting composition info somewhere in my code like:</p> <pre><code>compositionInfo({ model: viewModelInstance, view: viewName, activate: viewModelInstance.activate }); </code></pre> <p>And this is my view:</p> <pre><code>&lt;div id="service-container" data-bind="compose: { model: compositionInfo().model, view: compositionInfo().view, activate: compositionInfo().activate}"&gt; </code></pre> <p>At the first time, the composition works fine. But on the next time when the <code>compositionInfo</code> changes (using the same lines and in the same place of the code), nothing happens. </p> <p>The first time there is a <code>["Activating",...]</code> in the log window. But in the second time there's no such log or <code>["Binding"]</code> log.</p> <p>I've traced the Durandal and Knockout code and find out that in the <code>knockout-2.3.0.debug</code> file there's a <code>evaluateImmediate()</code> function which runs this line on first time (correct ones):</p> <pre><code>var newValue = readFunction.call(evaluatorFunctionTarget); </code></pre> <p>and causes the composition to start to activating the model.</p> <p>But when it's not working in the <code>evaulateImmediate()</code> it returns some lines above by this code:</p> <pre><code>// Don't dispose on first evaluation, because the "disposeWhen" callback might // e.g., dispose when the associated DOM element isn't in the doc, and it's not // going to be in the doc until *after* the first evaluation if (_hasBeenEvaluated &amp;&amp; disposeWhen()) { dispose(); return; } </code></pre> <p>What is this code for? <strong>Everything works fine if I comment these lines</strong>.</p> <p>This problem varies computer to computer. On my computer in most cases it just work the first time. but on other computer it works most of the time and fails about 3/10 cases.</p> <p>FYI I'm using Durandal 1.1.1 and Knockout 2.3.0</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.
 

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