I am trying to populate a dropdown using knockout. The array that I use to populate the optionsText is an array of JSON objects. I need the optionsValue to be either the index of the object in the array or a sequential number.
I have the following code in my viewModel:
self.job.submitOptionsArray = this.collection.toJSON();
this.job.applyPreset = ko.observableArray(self.job.submitOptionsArray);
and in my view:
<select name="" id="applyPreset" data-bind="options: applyPreset, optionsText: 'name', optionsValue: '???', value: somfn"></select>
I need a solution that does not use jQuery.