From 80e384e2b0cd6bc2f80a002071400ff6fba35c4b Mon Sep 17 00:00:00 2001 From: theMarvin Date: Thu, 1 Sep 2011 17:28:58 +0300 Subject: [PATCH] Sorry for my bad english! I hope you are getting it: I am using datepicker and timepicker as standalone instances on one single page. By using the "altField" the base "_updateAlternate" sets the val() of the altField to the date value of the datepickers, not to the properly val() of the timepickers instances. So i override it and check if the "altFieldTimeOnly" option is set and then put the right formatted time in the altField's val(). --- jquery-ui-timepicker-addon.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 123bfb6d..6323ce41 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -1158,6 +1158,28 @@ $.datepicker._setDateDatepicker = function(target, date) { this._setTimeDatepicker(target, tp_date, true); }; +//####################################################################################### +//override _updateAlternate() to avoid date strings on altFields at initalization if +//using datepicker and timepicker as standalone on one page +//####################################################################################### +$.datepicker._updateAlternate = function(inst) { + var altField = this._get(inst, 'altField'); + if (altField) { // update alternate field too + var altFormat = this._get(inst, 'altFormat') || this._get(inst, 'dateFormat'); + var date = this._getDate(inst); + var timeOnly = this._get(inst, 'altFieldTimeOnly'); + if(timeOnly){ + tp_inst = this._get(inst, 'timepicker'); + tp_inst._formatTime(); + var dateStr = tp_inst.formattedTime; + $(altField).each(function() { $(this).val(dateStr); }); + } else { + var dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst)); + $(altField).each(function() { $(this).val(dateStr); }); + } + } +} + //####################################################################################### // override getDate() to allow getting time too within Date object //#######################################################################################