更新:尝试制作小提琴来重现问题:http: //jsfiddle.net/gY2JV/29/ 结束更新
我有一个来自 DocModel 类型的服务器的对象。它的层次结构看起来像这样。
Class DocModel:
Property Rows As List(Of DocRowModel)
Class DocRowModel:
Property Documents As List(Of Doc)
Class Doc:
Contains some scalar properties
我在以下视图模型中使用它:
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 中的内容可能与问题无关——我只是在 Documents 中的每个 Document 上映射一堆标量属性):
<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>
当我在淘汰赛尝试更新视图模型之前中断时,我可以看到 response.d 正在以正确的格式返回正确的数据,但是堆栈空间不足。那是怎么回事。