I'm using the options binding on a select list used in a jQuery template:
<select data-bind="options: contactsViewModel.emailTypes, optionsText: 'Value', value: EmailType"></select>
The template is called with a knockout foreach for multiple email addresses.
EmailTypes is a list of emailtype objects The email object consist of the Value property which contains the string value of the email address, an Id property which contains a Guid id and an email type property which contains the emailtype object.
The emailtype object consists of the Value property which contains the name of the email type and a guid id.
The dropdown is correctly filled with the available email types, but the dropdown doesn't select the right item. It doesn't reflect the value of the object bound to it.
EDIT: The template with the showed select line is getting called by this: tbody data-bind="template: { name: 'emailTemplate', foreach: contactsViewModel.selectedContactEmails }">
selectedContactEmails is an observableArray filled with email objects, looking like this in Json:
{"EmailType":{"Value":"Home","Id":"191e8a64-8110-493c-b443-3063ff3a852a"},"ParentId":"191e8a64-8110-493c-b443-3063ff3a852c","Parent":null,"Value":"[email protected]","Id":"a7aae8fd-6ca3-49ae-b529-124d37a148ca"}
The properties of these objects are converted to observables using the mapping plugin.
emailTypes is an observableArray filled with EmailType objects:
{"Value":"Home","Id":"191e8a64-8110-493c-b443-3063ff3a852a"}