Datepicker和谷歌浏览器不工作

Datepicker和谷歌浏览器不工作

本文介绍了jQuery UI Datepicker和谷歌浏览器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having some problems with jQueryUI Datepicker and Google Chrome. My datepicker is working as expected with IE8, Firefox and Safari. The problem is when clicking the datepicker connected textbox in Chrome. It gives me a crash page, "Oops, an error occurred...". On my page there's textbox with a datepicker. The datepicker is language dependent and it loads the correct language settings dynamically. The datepicker should also display the month and year dropdowns. The code is as follows

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

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

如果我只用一个选项扩展datepicker,即changeYear,它可以在Chrome中使用。但是,如果我添加另一个选项,即changeMonth,则会发生Chrome中的崩溃。

If I only extend the datepicker with one option, i.e. changeYear, it works in Chrome. But if I add another option, i.e. changeMonth, the 'crash' in Chrome occurs.

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

Is my code incorrect? If so, how do I fix it?

任何帮助非常感谢!

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

I've updated the code to make it more readable. But still Chrome crashes on me if I add the changeMonth option.

$(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崩溃?

Anyone got any ideas of what might cause Chrome to crash?

推荐答案

其实...继承人我的解决方案:
theres一些问题与年的宽度选择元素
在CSS中的确切线是下一个:
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year {width:49%;}

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

如果您将其更改为某个非百分比值,则会修正该值...例如:
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select .ui-datepicker-year {width:75px;}

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;}

希望它有帮助,
marcelo

hope it helps,marcelo

这篇关于jQuery UI Datepicker和谷歌浏览器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:17