开发者

jQuery UI datepicker - IE issue when using year/month dropdowns

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

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

  2. Select a date (this works fine first time).

  3. Open the datepicker again, but this time, when you click on one of the year/month开发者_如何学Python dropdown lists, it appears briefly and then disappears, requiring a second click to get it to appear correctly.

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 loss as to what is causing it.


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

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?

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜