Click here to Skip to main content
13,047,131 members (58,773 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 24 Feb 2014

jQuery Datepicker Issue: Month and Year dropdowns in Internet Explorer Have to Click Twice

, 24 Feb 2014
Rate this:
Please Sign up or sign in to vote.
jQuery Datepicker Issue: Month and Year dropdowns in Internet Explorer have to click twice


While working on a legacy code base recently, I was facing an issue with the jQuery Datepicker.

For some reason, our customer's code is stuck with jquery-ui-1.8.13.custom.min.js. And the browser mandated for the application is Internet Explorer 9 with compatibility view with Internet Explorer 8 standards.


Load up a page with a Datepicker in it, with both the year and month dropdowns enabled. Click on one of the year/month dropdown lists, it appears and disappears. Click it again and it appears correctly.

After being clueless for a few minutes, I realized some event is getting triggered right after the click event that is causing the dropdown list to collapse. Then I noticed this:

<select class="ui-datepicker-year" onclick="DP_jQuery_1378903097959.datepicker._clickMonthYear
('#dp1378903097961');" onchange="DP_jQuery_1378903097959.datepicker._selectMonthYear('#dp1378903097961', this, 'Y');">


So the problem is jQuery Datepicker is binding two methods to the onchange and onclick events of the select. When I dug more, I found this:

_clickMonthYear: function(id) {
    var target = $(id);
    var inst = this._getInst(target[0]);
    if (inst.input && inst._selectingMonthYear) {
        setTimeout(function() {
        }, 0);
    inst._selectingMonthYear = !inst._selectingMonthYear;},


So I figured a quick hack is to get rid of the onclick method body in the plugin code itself. I could do that in the minified file (do it only if you know what you are doing!). Then a co-worker showed an even lower impact change, which is to remove the setTimeout() function body portion only – which, if doesn't break any of your existing functionality, is better.

On searching more, I found that this is an issue with that version of the plugin tracked here but I am not sure which version has the fix.


Ideally, I should override the onclick method using something like this. I am yet to try it because I have the "we-will-refactor-later" syndrome.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

India India
I dabble at many things and many of them at the same time. In short, I am a jack of all trades.

I am a software engineer by profession. My current area of expertise include .net Programming, Analysis, Software Operations and Architecture. I am equally conversant with greenfield and brownfield projects.

By hobby, I am a Technology Enthusiast, Blogger, Arm chair Movie Critic and self-proclaimed Cricket Expert. I have assisted in reviewing quite a few technology books so far. Sometimes I get lucky and take nice pics when I have my D-SLR in my hand.

Hope you found my article useful.

Also check out my blogs here:

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 24 Feb 2014
Article Copyright 2014 by CoderPanda
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid