Skip to content

Commit 5d05d23

Browse files
author
kumm
committed
Support datepicker onSelect handler.
1 parent 44fc32a commit 5d05d23

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

jquery-ui-timepicker-addon.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@ $.extend(Timepicker.prototype, {
457457
this._onTimeChange();
458458
this.timeDefined = timeDefined;
459459
}
460+
461+
//Emulate datepicker onSelect behavior. Call on slidestop.
462+
var onSelect = tp_inst._defaults['onSelect'];
463+
if (onSelect) {
464+
var inputEl = tp_inst.$input ? tp_inst.$input[0] : null;
465+
var onSelectHandler = function() {
466+
onSelect.apply(inputEl, [tp_inst.formattedDateTime, tp_inst]); // trigger custom callback*/
467+
}
468+
this.hour_slider.bind('slidestop',onSelectHandler);
469+
this.minute_slider.bind('slidestop',onSelectHandler);
470+
this.second_slider.bind('slidestop',onSelectHandler);
471+
}
460472
}
461473
},
462474

@@ -688,7 +700,8 @@ $.datepicker._selectDate = function (id, dateStr) {
688700
if (tp_inst) {
689701
tp_inst._limitMinMaxDateTime(inst, true);
690702
inst.inline = inst.stay_open = true;
691-
this._base_selectDate(id, dateStr);
703+
//This way the onSelect handler called from calendarpicker get the full dateTime
704+
this._base_selectDate(id, dateStr + tp_inst._defaults.separator + tp_inst.formattedTime);
692705
inst.inline = inst.stay_open = false;
693706
this._notifyChange(inst);
694707
this._updateDatepicker(inst);

0 commit comments

Comments
 (0)