jQuery UI datepicker闪烁问题

时间:2018-12-07 07:35:32

标签: javascript jquery jquery-ui jquery-ui-datepicker

我正在使用jquery ui datepicker。我在beforeShow方法中设置了它的位置。问题是,当datepicker用right:0px固定时,单击该字段会在左侧产生闪烁效果这样一来,日历在单击后便会显示在左侧,然后便会获得正确的位置。仅在加载后的INITIAL单击中发生这种情况。 JS代码

$('.schedule-a-tour #sat-moveindate').datepicker({
    minDate: 0,
    dateFormat: 'dd/mm/yy',
    onSelect: function () {
          $('.date-field #ui-datepicker-div').css({ 'position': 'absolute', 'right': '0px', 'top': '42px', 'z-index': '999' });
        $(this).data('datepicker').inline = true;
        if ($('#sat-moveindate-error').hasClass('error')) {
            $('#sat-moveindate-error').hide();
        }
        var dateSelection = $(".schedule-a-tour #sat-moveindate").datepicker("getDate");
        if (dateSelection !== null) {
            $('.input-date').find('.date-field').addClass('focused');
            $('.ui-datepicker').css('display', 'none');
        }
    },
    beforeShow : function(input,inst){
        if(arabicSite){
        window.setTimeout(function () {
           $('.date-field #ui-datepicker-div').css({ 'position': 'absolute', 'right': '0px', 'top': '42px', 'z-index': '999' });
            }, 1);
        }else {
              window.setTimeout(function () {
           $('.date-field #ui-datepicker-div').css({ 'position': 'absolute', 'left': '0px', 'top': '42px', 'z-index': '999' });
            }, 1);
        }
    }





});

请帮助。

0 个答案:

没有答案