1

I have an issue with a jQuery date picker which will work fine in Chrome or in IE9, however in IE8, it will close whenever someone clicks on the month/year change arrows at the top, or selects a date, it closes and displays a random date within the month currently selected (with the current issue it's selecting 18th, but I've seen it select other dates too - aside from the one actually clicked). We're using jQuery 1.8.0 and other frameworks (underscore and knockout) throughout the product, but the other frameworks are not in use on other pages

This is an internal system, so it's not out in the wild, but unfortunately, our users are constrained to only having IE8 as they are on windows XP and Chrome is disallowed by our network administrators. So while I can debug it and see it work in IE9 or Chrome, that's of no help to our users.

JS Code:

$(function () {
    $('.date-field').each(function () {
        var $this = $(this);
        if ($this.data('bound'))
            return;
        $this.datepicker({
            format: 'dd-mm-yyyy'
        }).data('bound', true);
    });
});

Html Code:

<input type="text" class="span3 date-field" name="FromDate">

There is other Javascript in many of the pages, and other functions in the page in question, but there's too much to paste and in this case there are no errors being thrown to any consoles (IE8/9 or Chrome) when debugging the javascript - it's just closing the datepicker when anything is clicked and not setting the value.

I'm a little confused - I've googled around and although I can find other issues with datepickers closing, they're usually around them not closing and some of them that do appear to be on the right track are not answered. I've also tried upgrading the jQuery version to 1.9.0, but it's made no difference - the problem and behaviour persist.

I've set up a jsFiddle - http://jsfiddle.net/mCVaY/7/ - which encapsulates the problem, but - irritatingly - jsFiddle seems not to work under IE8... (or maybe I'm doing it wrong - it's IE8 standards/browser mode within IE9 that I have to test with as I'm on Win 7 not XP...)

Any help greatly received, please let me know if I can provide any more information.

4

1 に答える 1

0

これは、プロジェクトに含まれていた日付ピッカーのブートストラップによるもので、私は気づいていませんでした。jQuery の日付ピッカーではありませんでした。これは、表示される日付の形式を設定するために dateFormat の代わりに format 属性が使用されている理由と、問題に対する答えを見つけるのが非常に困難であった理由を説明しています!

同じ問題に関連するフォーラムに問題があります: https://github.com/eternicode/bootstrap-datepicker/issues/144

最新バージョンに更新すると、問題が修正されました。

于 2013-02-19T14:33:38.940 に答える