here is my code:
var Feed = function (searchTerm, feeditems)
{
this.ID = 1;
this.SearchTerm = searchTerm;
this.FeedItems = ko.observableArray(feeditems);
};
var FeedItem = function(userName, message)
{
this.UserName = userName;
this.Message = message;
};
var viewModel = {
Feeds: ko.observableArray()
};
ko.applyBindings(viewModel);
function getFeedData()
{
var url = "/Feed/GetFeedData";
$.getJSON(url, function (data)
{
$.each(data, function ()
{
viewModel.Feeds[0].FeedItems.unshift(new FeedItem(this.UserName, this.Message));
});
});
window.setInterval("getFeedData()", TIMEDELAY);
}
I can't figure out how to update the FeedItems of the first Array element of Feeds. basically: viewModel.Feeds[0].FeedItems.unshift does not work... :(
when i just checking viewModel.Feeds, it gives me all the methods, but with viewModel.Feeds[0] it says it is undefined.
so, how to update the observable array of the first element of the observable array?
thanks!