JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cloud.github.com/downloads/SteveSanderson/knockout/knockout-2.1.0.js"></script>
<input type="date" readonly="true" data-bind="value: computedDate"/>
JavaScript
// Configure knockout
var model = {
date: ko.observable(new Date())
};
model.computedDate = ko.computed(function() {
var date = model.date();
var month = (date.getMonth() + 1);
var day = date.getDate();
if(month < 10)
month = "0" + month;
if(day < 10)
day = "0" + day;
return date.getFullYear() + '-' + month + '-' + day;
}, model);
ko.applyBindings(model);
// Change the input value programatically
setTimeout(function() { model.date(new Date("01/01/2001")); }, 2000);
////////////// Here's your listener ///////////////////
model.computedDate.subscribe(function(newValue) {
alert("changed to " + newValue);
});