jQuery UI datepicker - 使用年/月下拉菜单时的IE问题 [英] jQuery UI datepicker - IE issue when using year/month dropdowns

查看:87
本文介绍了jQuery UI datepicker - 使用年/月下拉菜单时的IE问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在IE中遇到了一个问题,使用了jQuery UI datepicker脚本:

I have recently encountered a problem in IE, using the jQuery UI datepicker script:


  1. 加载一个带有datepicker,显示年份和月份下拉列表。

  1. Load up a page with a datepicker on it, showing both the year and month dropdowns.

选择日期(这是第一次正常工作)。

Select a date (this works fine first time).

再次打开日期选择器,但这一次,当您单击其中一个年/月下拉列表时,它会短暂显示然后消失,需要再次单击才能使其正确显示。 / p>

Open the datepicker again, but this time, when you click on one of the year/month dropdown lists, it appears briefly and then disappears, requiring a second click to get it to appear correctly.

我有一个小测试页面(见下文),并使用jQuery 1.4.4和jQuery UI 1.8进行了测试。 10(我的生产配置)和jQuery 1.5.2和jQuery UI 1.8.12并且能够在两种情况下重现它(使用IE9和IE6)。

I have a small test page (see below) and have tested this using jQuery 1.4.4 and jQuery UI 1.8.10 (my production configuration) and jQuery 1.5.2 and jQuery UI 1.8.12 and been able to reproduce it in both cases (using IE9 and also in IE6).

<head>
<script type="text/javascript">

    $(document).ready(function () {

        $("#testDate").datepicker({changeYear:true, 
                    changeMonth:true, 
                    constrainInput:true, 
                    buttonText:'Choose', 
                    showOn:'both', 
                    showButtonPanel:false, 
                    buttonImageOnly:true});
    });

</script>
</head>
<body>
    <h2>Test</h2>
    <input type="text" id="testDate" />
</body>

我一直在尝试通过缩小的脚本进行调试,我必须看到这种情况发生在哪里,但是我有点亏......

I've been trying to debug through the minified script that I have to see where this is happening, but I'm at a bit of a loss...

推荐答案

如果你看一下未缩小的来源此处(1.8.12)相关功能是这样:

If you look at the un-minified source here (1.8.12) the function in question is this:

/* Restore input focus after not changing month/year. */
_clickMonthYear: function(id) {
    var target = $(id);
    var inst = this._getInst(target[0]);
    if (inst.input && inst._selectingMonthYear) {
        setTimeout(function() {
            inst.input.focus();
        }, 0);
    }
    inst._selectingMonthYear = !inst._selectingMonthYear;
},

删除 setTimeout() call为我停止了IE6中的聚焦问题。不知道副作用可能是什么。我已经选择了几个日期与本地修改的jquery-ui,而似乎仍然可以在Chrome12和IE6中正常工作。 可能是jquery-ui团队的一员吗?

Removing the setTimeout() call stops the focusing problem in IE6 for me. Not sure what the side effect might be though. I've selected a few dates with a locally modified jquery-ui and it seems to still work OK in Chrome12 and IE6. Might be one for the jquery-ui team?

编辑找到错误报告 - 看起来像是预定的1.8.3

Edit Found the bug report - looks like it's scheduled for 1.8.3

这篇关于jQuery UI datepicker - 使用年/月下拉菜单时的IE问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆