jQuery UI datepicker binding
http://www.knockmeout.net/2011/07/another-look-at-custom-bindings-for.html
by Ehsan Sajjad
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css">
<script src="http://knockoutjs.com/downloads/knockout-2.2.1.debug.js"></script>
<select style="height: 26px;" data-bind="options: StateTitle, event: { change: ddlState }, optionsText: 'StateText', optionsValue: 'StateId', value: selectedState, optionsCaption: 'Choose State.....'"></select>
JavaScript
function AppViewModel() {
var self = this;
self.StateTitle = ko.observableArray([]);
self.selectedState = ko.observable();
var data = {
StateId:1,
StateText:'Demo'
}
self.StateTitle(data);
self.selectedState.subscribe(function (data) {
console.log(data)
});
self.ddlState = function (newValue) {
}
}
ko.applyBindings(new AppViewModel());