vali-admin
vali-admin copied to clipboard
Issue with datepicker plugin
Hi. I have a trouble when using the datepicker plugin. This control isn't aligned with the input.
I was using other plugin (https://gijgo.com/datepicker/example/bootstrap-4). It was my solution
This problem was reported to the team of datepicker. see https://github.com/uxsolutions/bootstrap-datepicker/issues/1941
As suggested this can be fixed with the following script.
// This wrapper fixes wrong placement of picker when container has margins.
var originaldatepicker = $.fn.datepicker;
$.fn.datepicker = function () {
var result = originaldatepicker.apply(this, arguments);
this.on('show', function (e) {
var $target = $(this),
$picker = $target.data('datepicker').picker,
top;
if ($picker.hasClass('datepicker-orient-top')) {
top = $target.offset().top - $picker.outerHeight() - parseInt($picker.css('marginTop'));
} else {
top = $target.offset().top + $target.outerHeight() + parseInt($picker.css('marginTop'));
}
$picker.offset({top: top});
});
return result;
}