javascript - Knockout observable subscribe doesn't recognize a change with date input in google Chrome -
weird issue knockout.js whereas won't recognize date has been selected after reset, same date.
to replicate in jsfiddle: http://jsfiddle.net/v5jcq/ follow these steps:
- pick date
- cllick reset
- pick same date you've picked in step 1
how? what? why?
code:
<input type="button" data-bind="click: resetdate" value="reset"> <input data-bind="value : estimateddeliverydate" type="date"> <span data-bind="html: selecteddate" /> var viewmodel = { estimateddeliverydate: ko.observable(), selecteddate: ko.observable() }; viewmodel.estimateddeliverydate.subscribe(function (date) { viewmodel.selecteddate("date selected: " + date); }); viewmodel.resetdate = function () { viewmodel.estimateddeliverydate(""); }; ko.applybindings(viewmodel);
n.b.: issue applicable google chrome v20+ comes built-in date picker html5 date input control. hence tags.
not sure why, not seem firing change
event in scenario. easy fix specify want listen input
event using valueupdate
additional binding like:
<input data-bind="value : estimateddeliverydate, valueupdate: 'input'" id="estimateddeliverydate" name="estimateddeliverydate" type="date"><span data-bind="html: selecteddate" />