jQuery datepicker在IE8中遇到麻烦?

我确实看到了几个类似的线程,但后来他们发现是不同的问题…我的似乎是浏览器特定的问题,因为我的日期选择器在Firefox中工作正常,但肯定不在IE8中。 这是我原来的问题和源代码

我将我的datepicker更新为jQuery UI Datepicker 1.8.11 …但它仍然无法在IE 8中运行! 弹出日期选择器就好了,但没有事件发生。 我是说没有点击……没有任何反应……

有任何想法吗?

嘿我不知道你是否已经解决了这个问题,但问题是任何附加的属性。 特别是如果你使用:

yearRange: '-100:+10' 

例如 …

这是您解决问题的方法:从http://satish.name/?p=19复制

jQuery datepicker在IE中为DOM元素添加了一个新属性。 如果您尝试从现有元素动态复制添加新DOM元素,则datepicker将无法在IE中工作,因为新添加的DOM元素引用旧的jQuery属性。 解决此问题的一种方法是删除属性,然后在元素上实例化datepicker类。 请参阅以下代码以获取此修复程序。

 //newDiv is the new added dom element with innerHTML jQuery("#newDiv").find(".datePicker").each(function() { //removing jquery added attribute as this is causing the dynamically // added DOM elem referring old DOM element from it is copied. if (jQuery.browser.msie) { var jqaddedattr; jQuery(this.attributes).each(function() { if (this.name.search(/jQuery/) != -1) { jqaddedattr = this; } }); if (jqaddedattr) { jQuery(this).removeAttr(jqaddedattr.name); } } jQuery(this).datepicker({yearRange: '-100:+10', changeFirstDay:false}).val("").trigger('change'); }) 

干杯

这个jsFiddle包含了最基本的代码,可以在元素上使用jQuery UI datepicker。

http://jsfiddle.net/rbwh7/2/

我已经确认这可以在IE8,Chrome,Firefox上运行。

您可以测试一下,看看这是否适合您?

这是进一步的信息而不是答案,但不幸的是,添加评论太长了。

我看到的问题是DatePicker正确显示但没有一个事件正确触发(例如点击日期或月份导航什么都不做)。

我已将此问题缩小到在Windows 2008 R2 x64上运行的特定版本的IE8(v8.0.7600.16385)。 我们在同一操作系统上有其他虚拟机,但IE8的版本不同,不会出现此问题。 我们还没有看到IE8在Windows XP,Vista,2003或7上运行的问题。它在Firefox和Chrome中也能正常运行。

我已经尝试了mahatmanich引用的修复程序,但这并没有解决问题(尽管我们不使用yearRange选项)。

我还完全更新了Windows(不包括IE9),但这并没有更新IE8版本号或修复问题。

最后,我将jQuery更新为1.7.1,将jQuery UI更新为1.8.17,但两种更新都没有解决问题。

有没有人有任何其他想法或信息?

我有一个类似的问题。 在我的情况下,我必须在datetimepicker弹出框中单击一次以获得焦点,并且第二次在IE8中触发实际事件。

在声明datetimepicker选项时添加以下选项解决了我的问题:

 validateOnBlur: false 

我现在使用jQuery DateTimePicker插件v2.2.5。 当它在IE8上运行时,日期选择器在我点击某天的td元素时没有响应。点击事件似乎没有被触发。 然后我去了控制台,我发现了datepicker脚本的运行时错误。 当其他人调用它的函数时,变量为null。 调试后我发现变量在以下代码中设置为null。(我只是在选项中将validateOnBlur设置为false以解决问题..)

 if( options.validateOnBlur ) { input.off('blur.xdsoft') .on('blur.xdsoft', function() { if( options.allowBlank && !$.trim($(this).val()).length ) { $(this).val(null); //*************************************************** // After running of the following line, the variable //_xdsoft_datetime.currentTime was setting to null. // It seemed that the order of events fired not as //expected.Valedate runned before the selected day value sets to input.. // So I just set validateOnBlur to false in options to resolve the issue.. datetimepicker.data('xdsoft_datetime').empty(); }else if( !Date.parseDate( $(this).val(), options.format ) ) { $(this).val((_xdsoft_datetime.now()).dateFormat( options.format )); datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); } else{ datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val()); } datetimepicker.trigger('changedatetime.xdsoft'); }); } 

我有同样的问题。 我无法更改月份或年份,当它在jquery对话框上打开datetimepicker时。

我可以解决这个问题,添加一个onShow监听器,将焦点放在另一个输入上。 这是我的源代码:

 $(".date").datetimepicker({ dayOfWeekStart : 1, timepicker : false, scrollMonth : false, scrollInput : false, format : 'd/m/Y', formatDate : 'd/m/Y', lang : 'es', onShow : function() { $('#anotherInput').focus(); }, });