To be displayed properly.
The calendar is shown with its position affects by the margins of the body element.
I've added via DevTools margins to the body on the sandbox site and it manifested the same behavior.
1.6.1.
Add margin-top and margin left with positive and negative values and see.
Here's the fiddle :)
Created a quick patch for this issue. After including bootstrap-datepicker add this code:
<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;
}
</script>
Generally it repositions picker whenever it is shown. Works for version 1.6.4.
Hope sb will find it useful, and the original code will be fixed soon!
this solved my problem, thanks!!
great solution, thanks!!
The patch by @imbrish still works as of now, tested with version 1.8.0
This issue still persists in version 1.9.0, but this solution still works for me. Thanks
Most helpful comment
Created a quick patch for this issue. After including bootstrap-datepicker add this code:
Generally it repositions picker whenever it is shown. Works for version
1.6.4.Hope sb will find it useful, and the original code will be fixed soon!