2

このコンテナwithレス バインディングは、期待どおりに bindingContext を設定しません。それはまだラダーの親に設定されています。

<!-- ko with:ladder -->
<table>
    //Context here is the $root object, not $root.ladder
    //some foreach binding here
</table>

<a  href="#" data-bind="click: addPages">Add 4 pages</a>
<!-- /ko -->

ただし、このコンテナフル メソッドは正常に機能します。

<table class="ladder-table" data-bind="with:ladder">
    //the context is correctly set to ladder in this instance
    //some foreach binding here
</table>
<br />
<a  href="#" data-bind="click: ladder.addPages">Add 4 pages</a>

誰がそれがどうなっているのか知っていますか?Google は結果を提供しませんでした。

4

1 に答える 1

0

この回答が説明しているように、問題はノックアウトではなくデュランダルにあり ます。

つまり、Durandal ではビューごとに 1 つのルート要素しか許可されません。

goodView.html

<div>
    <--ko foreach:stuff-->
      //stuff
    <--/ko-->
</div>

badView.html

<div>
   <stuff/>
</div>
<--ko foreach:stuff-->  //these elements are stripped out
  //stuff
<--/ko-->

ありがとう@nemesv

于 2013-08-16T21:43:43.520 に答える