vali-admin icon indicating copy to clipboard operation
vali-admin copied to clipboard

Issue with datepicker plugin

Open johanvf84 opened this issue 5 years ago • 1 comments

Hi. I have a trouble when using the datepicker plugin. This control isn't aligned with the input.

2018-09-28 22_31_27-custom form elements - vali admin

I was using other plugin (https://gijgo.com/datepicker/example/bootstrap-4). It was my solution

johanvf84 avatar Sep 29 '18 03:09 johanvf84

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;
    }



arbh89 avatar Nov 02 '18 17:11 arbh89