I am just started to use knockoutjs. I try to bind the select option value with knockout data-bind property.But am not able to get the array values as different options. It will populate as coma separetd. i had attaching the sample code i tryied.I hope some others will also face the same strange error.
self.availableStates = new Array();
for (var i=0;i<self.allStates.length;i++)
{
if (self.allStates[i]['name'] != null)
self.availableStates.push(self.allStates[i]['name'])
}
self.availableStates = ko.observableArray([self.availableStates]);
Expecting result:
<select id="drpDwnLst" data-bind="options: availableStates">
<option value="">State4</option>
<option value="">State3</option>
<option value="">State2</option>
<option value="">State1</option>
</select>
Actual result
<select id="drpDwnLst" data-bind="options: availableStates">
<option value="">State4,State3,State2,State1</option>
</select>