4

我在使用 jQueryUI Datepicker 和 Google Chrome 时遇到了一些问题。我的日期选择器在 IE8、Firefox 和 Safari 上按预期工作。问题是在 Chrome 中单击日期选择器连接的文本框时。它给了我一个崩溃页面,“糟糕,发生错误......”。在我的页面上有一个带有日期选择器的文本框。日期选择器依赖于语言,它会动态加载正确的语言设置。日期选择器还应显示月份和年份下拉菜单。代码如下

$(function() {
    $.datepicker.setDefaults($.extend({ changeMonth: true, changeYear: true }, $.datepicker.regional['']));

    $('#<%= TextBoxBirthDate.ClientID %>').datepicker($.datepicker.regional[$('#LabelRegionalSettings').val()]);});

如果我只用一个选项扩展日期选择器,即 changeYear,它可以在 Chrome 中使用。但是,如果我添加另一个选项,即 changeMonth,Chrome 中的“崩溃”就会发生。

我的代码不正确吗?如果是这样,我该如何解决?

任何帮助是极大的赞赏!


我已经更新了代码以使其更具可读性。但是,如果我添加 changeMonth 选项,Chrome 仍然会崩溃。

$(function() {
    $.datepicker.setDefaults($.datepicker.regional['']);
        $('#<%= TextBoxBirthDate.ClientID %>').datepicker($.datepicker.regional[$('#LabelRegionalSettings').val()]);<br />
        $('#<%= TextBoxBirthDate.ClientID %>').datepicker('option', 'changeMonth', true);
        $('#<%= TextBoxBirthDate.ClientID %>').datepicker('option', 'changeYear', true);
        $('#<%= TextBoxBirthDate.ClientID %>').datepicker('option', 'yearRange', '-50:+0');
    });

有人对可能导致 Chrome 崩溃的原因有任何想法吗?

4

2 回答 2

1

actually...heres my solution: theres some issue with the width of the year select element the exact line in the css is the next: .ui-datepicker select.ui-datepicker-month, .ui-datepicker select.ui-datepicker-year { width: 49%;}

if you change it to some non percentage value it fixes it... something like this: .ui-datepicker select.ui-datepicker-month, .ui-datepicker select.ui-datepicker-year { width: 75px;}

hope it helps, marcelo

于 2010-04-21T15:52:34.743 回答
0

固定的!

我有同样的问题..我实际上发现它是我使用的 CSS 文件的问题.. 即:

jquery.ui.core.css
jquery.ui.theme.css
jquery.ui.datepicker.css

我不知道这是为什么.. chrome 中的调试不如 firefox 愉快.. 但我的简单解决方法是重新下载我想要的主题并解决了问题。

希望有帮助

j


我也有同样的问题。。有人解决了吗?有人在这里发布了一个潜在的工作: http ://groups.google.com/group/jquery-ui/browse_thread/thread/1ea5315618087a9d?pli=1

(通过围绕用户确定的问题包装 setTimeout ,但这对我也不起作用。)

于 2010-03-24T01:19:50.727 回答