一个特性,这是我的代码,其是不工作knockout.js ko.mapping.fromjs包括在结合
var getUpdates = setInterval(function() {
$.getJSON("@Url.Action("GetLists", "Home")?id=" + self.selectedboard(), function (data) {
var mapping = {
// only include these two properties
'include': ["cardlists"]
}
ko.mapping.fromJS(data, mapping, self.lists);
ko.applyBindings(helloWorldModel);
});
}, 3000);
数据被返回
[{ “板卡ID”:1,“boardname “:” asdasd”, “listid”:15, “LISTNAME”: “asdasd”, “cardvisiblity”:真 “showlist”:假 “listremove”:假 “showRenderTimes”:假 “cardlists”:[{ “CardId中”:23, “cardname”: “7”, “listid”:15},{ “CardId中”:24, “cardname”: “3”, “listid”:15},{ “CardId中”:27, “cardname”: “asdasd”, “listid”:15},{ “CardId中”:38, “cardname”: “asdasd”, “listid”:15}]},{ “板卡ID”:1, “boardname”: “asdasd”, “listid”:22, “LISTNAME”: “asdasd”,” cardvisiblity “:真” showlist “:假” listremove “:假” showRenderTimes “:假” cardlists “:[{” CardId中 “:33,” cardname “:” asdasd”, “listid”:22}, { “CardId中”:39, “cardname”: “asdasd”, “listid”:22},{ “CardId中”:41, “cardname”: “qdasd”, “listid”:22}]},{ “板卡ID” :1, “boardname”: “asdasd”, “listid”:23, “LISTNAME”: “asdasd”, “cardvisiblity”:真实的, “showlist”:假的, “listremove”:假的, “showRenderTimes”:假” cardlists “:[{” CardId中 “:34,” cardname “:” asdasd”, “listid”:23},{ “CardId中”:40 “cardname”: “asdasd”, “listid”:23}]}, { “板卡ID”:1, “boardname”: “asdasd”, “listid”:24, “LISTNAME”: “asdasd”, “cardvisiblity”:真 “showlist”:假 “listremove”:假 “showRenderTimes” :假 “cardlists”:[{ “CardId中”:35, “cardname”: “qweqwe”, “listid”:24},{ “CardId中”:36, “cardname”: “asdasd”, “listid”:24 },{ “CardId中”:37, “cardname”: “asdasd”, “listid”:24},{ “CardId中”:42, “cardname”: “sdfsdf”, “listid”:24},{ “CardId中” :43,“cardname”:“asdasd”,“listid”:24}]}]
如何在绑定中仅包含cardlist?
如何在绑定中排除showRenderTimes?
忽视的手段,例如,如果cardvisiblity是假它将保持假的?如果它来了,它不会受到影响 – maztt
不,这意味着如果'cardvisiblity'是你的对象的一部分,你告诉映射插件忽略映射的这个属性。它不会成为绑定模型的一部分。 –
cardvisiblity不会成为self.lists的一部分吗? – maztt