Skip to content

Commit 915d275

Browse files
Fixes trentrichardson#750 - datetimeRange clears the time portion when prepopulated
1 parent 80f5050 commit 915d275

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

dist/jquery-ui-timepicker-addon.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,10 @@
17611761
onselect = null,
17621762
overrides = tp_inst._defaults.evnts,
17631763
fns = {},
1764-
prop;
1764+
prop,
1765+
ret,
1766+
oldVal,
1767+
$target;
17651768
if (typeof name === 'string') { // if min/max was set with the string
17661769
if (name === 'minDate' || name === 'minDateTime') {
17671770
min = value;
@@ -1819,11 +1822,21 @@
18191822
} else if (onselect) {
18201823
tp_inst._defaults.onSelect = onselect;
18211824
}
1825+
1826+
// Datepicker will override our date when we call _base_optionDatepicker when
1827+
// calling minDate/maxDate, so we will first grab the value, call
1828+
// _base_optionDatepicker, then set our value back.
1829+
if(min || max){
1830+
$target = $(target);
1831+
oldVal = $target.datetimepicker('getDate');
1832+
ret = this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
1833+
$target.datetimepicker('setDate', oldVal);
1834+
return ret;
1835+
}
18221836
}
18231837
if (value === undefined) {
18241838
return this._base_optionDatepicker.call($.datepicker, target, name);
18251839
}
1826-
18271840
return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
18281841
};
18291842

0 commit comments

Comments
 (0)