JQuery DatePicker 年份下拉列表在 Firefox 中消失

发布于 2025-01-04 18:45:35 字数 632 浏览 3 评论 0原文

当用户更改 JQuery UI 日期选择器上的月份/年份时,我试图保持所选日期。这是我的代码:

    $("input[class='datePicker hasDatepicker']").each(function (index) {

         $(this).datepicker("option", "onChangeMonthYear",
            function (year, month, inst) {
                var currDate = $(this).datepicker("getDate");

                if (currDate)
                    $(this).datepicker("setDate", month + "/" + currDate.getDate() + "/" + year);
          });
    });

该代码在 IE 和 Chrome 中运行良好,但在选择日期并尝试更改月份/年份后,年份的下拉列表在 Firefox 中消失。有什么想法吗???谢谢。

编辑:

看起来该错误与我正在调用的“setDate”方法直接相关。如果注释掉就没有问题了。

I'm trying to maintain the selected date when the user changes the month/year on the JQuery UI Datepicker. Here's my code:

    $("input[class='datePicker hasDatepicker']").each(function (index) {

         $(this).datepicker("option", "onChangeMonthYear",
            function (year, month, inst) {
                var currDate = $(this).datepicker("getDate");

                if (currDate)
                    $(this).datepicker("setDate", month + "/" + currDate.getDate() + "/" + year);
          });
    });

The code works fine in IE and Chrome, but the dropdownlist for the year disappears in Firefox after you select a date and try to change the month/year. Any ideas??? Thanks.

EDIT:

It looks like the error is directly related to the "setDate" method I'm calling. If you comment it out, there isn't a problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请叫√我孤独 2025-01-11 18:45:35

解决方案是我应该立即检查的。我使用的是版本 jqueryui/1.8.12/jquery-ui.min。 js 以及当我更新到最新版本时jqueryui/1.8.16/jquery-ui.min.js 它工作正常。

The solution was something I should have checked right away. I was using version jqueryui/1.8.12/jquery-ui.min.js and when I updated to the latest version jqueryui/1.8.16/jquery-ui.min.js it works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文