Reputation: 2850
I am not sure why I am getting this error:
Uncaught Error: Unable to parse bindings. Message: ReferenceError: data is not defined; Bindings value: options: dateOptionsArray,optionsText: data,value: data knockout-2.2.1.debug.js:1936 ko.utils.extend.parseBindingsString
for this model:
function ViewModel(jsonModel) {
var self = this;
self.dateOptionsArray = ["YYYY-MM-DD", "YYYY-MM-DD HH:MM"]; //todo make this dynamic
in this html:
<select id="f" data-bind="options: dateOptionsArray,optionsText: data,value: data"></select>
Upvotes: 0
Views: 767
Reputation: 139778
First you need to have a property named data
on order to the value
binding work:
function ViewModel(jsonModel) {
var self = this;
self.dateOptionsArray = ["YYYY-MM-DD", "YYYY-MM-DD HH:MM"];
self.data = ko.observable();
};
Second don't need to the optionsText
. You only need it when you have complex objects in your array and you want to specify which property KO should use for the select text. See also in the documentation:
<select id="f" data-bind="options: dateOptionsArray, value: data"></select>
Demo JSFiddle
Upvotes: 2