0
UPDATE: 問題を再現するためにバイオリンを作るしようとすると: http://jsfiddle.net/gY2JV/29/ ENDのUPDATEKnockoutJSネストされた配列のマッピング更新
私はタイプDocModelのサーバーからオブジェクトを持っています。その階層は次のようになります。
Class DocModel:
Property Rows As List(Of DocRowModel)
Class DocRowModel:
Property Documents As List(Of Doc)
Class Doc:
Contains some scalar properties
私は、次のviewmodelでそれを使用します。
HpDocs.DocsVM = function (data) {
ko.mapping.fromJS(data, {}, this);
};
HpDocs.DocsVM.prototype = {
getDocs: function (filter) {
var self = this;
$.ajax({
url: getMethodUrl("GetDocs"), // server call returns object of type DocModel
data: "{'filter': " + filter + "}",
success: function (response) {
ko.mapping.fromJS(response.d, {}, self.MyDocs); // out of stack space
}
})
}
};
HpDocs.dbGetDocs = function (filter) {
$.ajax({
url: getMethodUrl("DbGetDocs"), // server call returns object of type DocModel
data: "{'filter': " + filter + "}",
success: function (response) {
myDocsViewModel = new HpDocs.DocsVM({
MyDocs: ko.mapping.fromJS(response.d)
});
var bindingScope = $("#divMyDocs")[0];
ko.applyBindings(myDocsViewModel, bindingScope);
HpDocs.hideProgress();
}
})
};
そしてここでは、私の見解は、(TD内のものは、おそらく問題とは無関係であるだ - 私はちょうど上のスカラープロパティの束をマッピングしています各ドキュメントでのドキュメント):
<table id="tblMyDocs">
<tbody data-bind="foreach: MyDocs.Rows">
<tr data-bind="foreach: Documents">
<td style='text-align: center;'>
<div data-bind="attr: {title: Tooltip}" class='DocumentObject' runat="server" width="40px">
<a data-bind="attr: {href: FullServerPath}">
<img data-bind="attr: {src: IconPath, alt: Tooltip}" />
</a>
<br />
<textarea runat="server" readonly="readonly"
data-bind="html: DisplayName"
class="doclabel" rows="2" cols="10" wrap="hard"
</textarea>
</div>
</td>
</tr>
</tbody>
</table>
私はノックアウトする前に壊れるのviewmodelを更新しようと、私はそのresponse.dが正しい形式で正しいデータを返して見ることができますが、それRUスタック領域外のns どうしたらいいですか?
私は、配列内のすべてのアイテムをループして明示的にそれぞれ1が観測作ってみます... – pabrams