1
更新值。這在UI更新值:淘汰賽不通過映射
PortfolioGeneral.CompanyName(item.CompanyName);
我可以手工編寫這些值的手,而是我想用一個映射。然而,這是行不通的:
PortfolioGeneral = ko.mapping.fromJS(item);
ko.applyBindings在調用以下函數之前已被調用。此調用應更新所有模型值。
function getPortfolioGeneral(portfolioId, PortfolioGeneral) {
$.ajax({
url: "/api/portfolio",
contentType: "text/json",
dataType: "json",
type: "GET",
data: { id: portfolioId },
success: function (item) {
//PortfolioGeneral = ko.mapping.fromJS(item);
PortfolioGeneral.CompanyName(item.CompanyName);
},
error: function (data) {
}
});
}