开发者

how to set the show position of datepicker?

dear i have a datepicker inside my form. after i click the textfield, datepicker show to up(reverse with drop down). how do i do if i want to show datepicker dropdown not dropup? http://img413.imag开发者_运维知识库eshack.us/img413/1460/screenshot5g.png


 $('.datetime').datepicker({
     dateFormat: 'm/d/yy',
     beforeShow: function (input, inst) {
         var offset = $(input).offset();
         var height = $(input).height();
         window.setTimeout(function () {
             inst.dpDiv.css({ top: (offset.top + height + 4) + 'px', left: offset.left + 'px' })
         }, 1);
     }

 });


Look for a solution over in this post. Is this what you were looking for?


expanding on Igor's answer. To position the calendar to the bottom right of the datepicker input element, use this:

$('.datepicker').datepicker({
    beforeShow: function (input, inst) {
        var offset = $(input).offset();
        window.setTimeout(function () {
            var calWidth = inst.dpDiv.width();
            var inpWidth = $(input).width() + parseInt($(input).css('padding'));
            inst.dpDiv.css({ left: offset.left + (inpWidth - calWidth) + 'px' })
        }, 1);
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜