Reputation: 773
I am having a very hard time using the foreach control flow binding in my project.
Fiddler: http://jsfiddle.net/mbynum/YVVbg/
Summery of Fiddler:
Javascript:
var viewModel = {
Chart: {
Name: "something"
},
VarsOptions: ko.observableArray([{
Name: "test1"},
{
Name: "Test2"}])
};
ko.applyBindings(viewModel);
HTML:
<h1>Something?</h1>
<ul data-bind:"foreach: VarsOptions">
<li data-bind="text: Name"></li>
</ul>
I am referencing the knockout: http://cloud.github.com/downloads/SteveSanderson/knockout/knockout-1.3.0beta.js from github: https://github.com/SteveSanderson/knockout/downloads
I have seen people on fiddler get this to work. I dont see how my code is different or why it might not be working. I am beginning to believe it might be the way I am setting up my javascript object.
Upvotes: 0
Views: 166
Reputation: 114792
Here is your issue:
<ul data-bind:"foreach: VarsOptions">
Should be:
<ul data-bind="foreach: VarsOptions">
Upvotes: 1