jQuery DatePicker如何在浏览日历时禁用自动日期选择? [英] jQuery DatePicker how to disable auto day selection while browsing calendar?

查看:142
本文介绍了jQuery DatePicker如何在浏览日历时禁用自动日期选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jQuery DatePicker中有一个令人讨厌的事情,如果你将它用作日历并依赖于所选日期。在每个月进行导航,它保持选定的一天在所有月份激活。我知道这个问题存在6个月以上,我已经向jQuery Team报告了这个问题。但是我想知道有没有解决方法或者如何禁用这种行为?

In jQuery DatePicker there is one annoying thing, if you using it as a calendar and depend on selected date. While navigating from month to month it keep selected day activated for all months. I know that this issue exist for more than 6 months and I have reported it to jQuery Team.However I would like to know is there any workarounds or how to disable this behaviour?

日历示例可以在 here 找到

推荐答案

这是我想出的解决方法。

here's a workaround I figured out.

$(function() {

    $("#datepicker").datepicker({
        onChangeMonthYear: function(year, month, inst) {
            var bMonth = (new Date(this.value)).getMonth() != month - 1;
            var bYear = (new Date(this.value)).getFullYear() != year;
            if (bMonth || bYear) {
            setTimeout(function() {
                $('.ui-state-active').removeClass('ui-state-active');
            }, 5);
            }
        }
    });
});​

这篇关于jQuery DatePicker如何在浏览日历时禁用自动日期选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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