Reputation: 117
I have a dropdown inside a foreach
<tbody data-bind="foreach: Details">
<tr style="border: none">
<select style="width: 130px"
data-bind=" optionsCaption: 'Choose...',
options: $data.filteredList, optionsText: 'number',
optionsValue: 'id'">
</select>
</tr>
This binding does not seem to work. When I debug I can see that the filter is updating but I never get any thing in the dropdown.
I added this:
<pre data-bind="text: ko.toJSON($data, null, 2)"></pre>
This is the result:
{
"Seed": 1,
"filteredList": [
{
"id": "a",
"number": "12"
},
{
"id": "b",
"number": "12"
}
}
And I can see that the filter values are changing.
Why would the dropdown be empty?
Upvotes: 3
Views: 1022
Reputation: 2493
Just change $data.filteredList
to $root.filteredList
in the binding if the filteredList
is a member of ModelView
.
Upvotes: 2