From d5d62f274909f839ec131e3adfc2434202340f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teemu=20P=C3=A4=C3=A4kk=C3=B6nen?= Date: Wed, 8 Jan 2014 15:00:46 +0200 Subject: [PATCH] Allow empty internal value if options.allowBlank is true --- jquery.datetimepicker.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jquery.datetimepicker.js b/jquery.datetimepicker.js index bd91030..ab3c474 100644 --- a/jquery.datetimepicker.js +++ b/jquery.datetimepicker.js @@ -446,11 +446,16 @@ .on('blur.xdsoft', function() { if( options.allowBlank && !$.trim($(this).val()).length ) { $(this).val(null); + datetimepicker.data('xdsoft_datetime').empty(); } else if( !Date.parseDate( $(this).val(), options.format ) ) { $(this).val((new Date()).dateFormat( options.format )); + datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); } - datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); + else ++ { ++ datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); + } datetimepicker.trigger('changedatetime.xdsoft'); }); } @@ -508,6 +513,10 @@ datetimepicker.trigger('xchange.xdsoft'); }; + _this.empty = function() { ++ _this.currentTime = null; ++ }; + _this.getCurrentTime = function( dTime) { return _this.currentTime; };