From 2eaafb253283bc0d3bdc312d7cf80078b41da3eb Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Mon, 23 Mar 2015 22:07:32 +0530 Subject: [PATCH 1/2] Added fix to update observable when date is entered manually --- src/datepicker.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/datepicker.js b/src/datepicker.js index 77d0c58..a8beb03 100644 --- a/src/datepicker.js +++ b/src/datepicker.js @@ -60,6 +60,15 @@ define( $(element)[widgetName]('setDate', newValue); }); + // When input value is changed update the observable as well + ko.utils.registerEventHandler(element, 'change', function() { + var date = $(element)[widgetName]('getDate'); + // If the date is changed in datepicker + if(options.value && options.value() - date !== 0) { + options.value($(element)[widgetName]('getDate')); + } + }); + ko.utils.domNodeDisposal.addDisposeCallback(element, function () { subscription.dispose(); }); From b3b3646fd512f4fcf0469d5b4e0028282797af2f Mon Sep 17 00:00:00 2001 From: Venkatesh Date: Mon, 23 Mar 2015 22:11:57 +0530 Subject: [PATCH 2/2] Added new line --- src/datepicker.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/datepicker.js b/src/datepicker.js index a8beb03..0200b68 100644 --- a/src/datepicker.js +++ b/src/datepicker.js @@ -63,6 +63,7 @@ define( // When input value is changed update the observable as well ko.utils.registerEventHandler(element, 'change', function() { var date = $(element)[widgetName]('getDate'); + // If the date is changed in datepicker if(options.value && options.value() - date !== 0) { options.value($(element)[widgetName]('getDate'));