加载ajax-json后重新加载淘汰js视图 我正在搞淘汰赛, 这是一个静态示例:
当数组更改时,此刷新,但是 这是一个动态示例: 这不是在init中刷新和加载 json部分在这里加载ajax-json后重新加载淘汰js视图 我正在搞淘汰赛, 这是一个静态示例:,ajax,json,knockout.js,mapping,Ajax,Json,Knockout.js,Mapping,当数组更改时,此刷新,但是 这是一个动态示例: 这不是在init中刷新和加载 json部分在这里 $.getJSON( "/echo/json/") .done(function( json ) { $.each(json.data.data, function(i, item){ console.log(item.name); // json Item data.push(JSON.stringify(
$.getJSON( "/echo/json/")
.done(function( json ) {
$.each(json.data.data, function(i, item){
console.log(item.name); // json Item
data.push(JSON.stringify(item)); // I push the json item in array
console.log(data); //array
})
})
谢谢大家看看这里:
getAttachments()函数应该只更新可观察数组的内容:
ajax调用:
$.post( "/echo/json/", "{}")
.done(function( json ) {
self.attachments([]);
$.each(data, function(i, item){
console.log(item.name); // json Item
self.attachments.push(item);
console.log(self.attachments()); //array
});
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
});
refresh()函数:
self.refresh = function() {
self.getAttachments();
//self.attachments(self.getAttachments());
//ko.mapping.fromJS(self.getAttachments(), self.attachments);
console.log("attachments:" + self.attachments());
}
谢谢你的帮助,我所需要的全部是“推”功能