Issue with ko.observableArray
Posted
by
user1574860
on Stack Overflow
See other posts from Stack Overflow
or by user1574860
Published on 2012-10-13T21:33:54Z
Indexed on
2012/10/13
21:36 UTC
Read the original article
Hit count: 166
I am using Knockout plugin. The following is my code. In this i am making getting the ceremony list from the server and then save that list in the array. But the problem is in IniitialCallForCeremonies(). The array is not initializing with the returned array from IniitialCallForCeremonies() function.
function CeremonyViewModel() {
var self = this;
self.Ceremonies = ko.observableArray(InitialCallForCeremonies());
}
$(document).ready(function () {
ko.applyBindings(new CeremonyViewModel());
});
function InitialCallForCeremonies() {
var request = $.ajax({
url: "address",
type: "GET",
async: false,
dataType: "JSON"
}).success(function (data) {
var tempArray = new Array();
$.each(data, function (index, value) {
tempArray.push(new Ceremony(value));
});
return tempArray;
});
}
function Ceremony(val) {
this.Id = val.Id;
this.Event = val.Event;
this.Date = val.Date;
this.Guest = val.Guest;
}
?
© Stack Overflow or respective owner