1

I have the following problem. I'm developing web application on asp.net mvc and using KnockoutJS in one of views. I have the following viewmodel

public class ExampleViewModel 
{
    public IEnumerable<Element> ElementsList { get; set; }
}

class Element
{
    public bool Required {get;set;}
}

option Required must be set with dropdown list. I have the following block code in view

<div data-bind="foreach: ElementsList">
    <select data-bind="attr: { name: 'ElementsList[' + $index() + '].Required' }, value: Required">
        <option value="true">Yes</option>
        <option value="false">No</option>
    </select>
</div>

when I select Yes or No from drop down and submit form I have appropriate value saved in database, but when I open this view in browser after that all values in drop down list are 'Yes'. Despite the fact that when I open view and debug it I can see with Quick Watch, that each value from ElementsList has correct value of Required option ('Yes' or 'No'), all dropdown lists have a value 'Yes'.

anykey3
  • 273
  • 5
  • 20
  • 3
    You're most likely experiencing [this issue](http://stackoverflow.com/questions/10510683/knockoutjs-version-2-1-0-bind-boolean-value-to-select-box). – Jeroen May 13 '13 at 16:59

0 Answers0