I have the following snippet JQuery inside an HTML file:
$.getJSON("/events/", function (data) {
viewModel = ko.mapping.fromJS(data);
ko.applyBindings(viewModel);
});
The code is executed when, for example, the user presses a button and returns JSON like:
{"Events":[{"Name":"Event1"},{"Name":"Event2"},{"Name":"Event3"}]}
This result is linked (using KnockoutJS) to:
<ul data-bind="foreach: Events">
<li><span data-bind="text: Name"></span></li>
</ul>
Everything works fine with the first call to $.GetJSON
. I get what I want, which is (browser output):
- Event1
- Event2
- Event3
But in subsequent calls to "$. GetJSON" I get the following error in Firebug:
containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling);
NotFoundError: Node was not found.
And I get no list item.
What I can be doing wrong?
Thank you very much in advance.