I’m just trying to get a knockout bound drop down working with asp.net master page. In the master page, I have the script references to jquery and knockout. In a sample content page, I have the following, but the select control never gets populated. What am I missing?
<asp:content id="Content1" contentplaceholderid="contentBody" runat="server">
<select data-bind="options: docTypes ,
optionsCaption: 'Choose document type',
optionsText: 'name',
value: chosenDocType"></select>
<script>
$(function(){
function emailViewModel() {
this.docTypes = [
{ name: "1" },
{ name: "2" },
{ name: "3" }
];
this.chosenDocType = ko.observable();
}
ko.applyBindings(emailViewModel);
});
</script>
</asp:content>
You are not instantiating the emailViewModel
Change
to this
Fiddle here