christiannaths / christiannaths/jquery-datetimepicker
Can't pass normal datepicker commands through datetimepicker
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
I couldn't figure out how to do a manual "hide" using the datetimepicker. With datepicker, you would just use $.datepicker("hide"). Not sure if this is the ideal way of handling it, but I came up with a solution.
Around line #300 I added a check to see if you are passing an "object" or a "string". Here's what I came up with:
// if object, assume defaults - DSJ
if (typeof o === "object") {
tp.defaults = $.extend({}, tp.defaults, o);
tp.defaults = $.extend({}, tp.defaults, {
beforeShow: function (input, inst) {
tp.hour = tp.defaults.hour;
tp.minute = tp.defaults.minute;
tp.second = tp.defaults.second;
tp.ampm = '';
tp.$input = $(input);
tp.inst = inst;
tp.addTimePicker(inst);
if ($.isFunction(o.beforeShow)) {
o.beforeShow(input, inst);
}
},
onChangeMonthYear: function (year, month, inst) {
// Update the time as well : this prevents the time from disappearing from the input field.
tp.updateDateTime(inst, tp);
if ($.isFunction(o.onChangeMonthYear)) {
o.onChangeMonthYear(year, month, inst);
}
},
onClose: function (dateText, inst) {
tp.updateDateTime(inst, tp);
if ($.isFunction(o.onClose)) {
o.onClose(dateText, inst);
}
}
});
$(this).datepicker(tp.defaults);
// if string, assume method - DSJ
} else if (typeof o === "string") {
$(this).datepicker(o);
}
Again, not sure if this is absolutely correct, but it seems to work.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.