jQuery 日期选择器在 IE8 中遇到问题? [英] jQuery datepicker having trouble in IE8?

查看:19
本文介绍了jQuery 日期选择器在 IE8 中遇到问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

i did see a couple of similar threads, but later they turned out to be different issues...mine seems a browser specific problem surely because my datepicker works fine in Firefox, but certainly not in IE8. Here is my original problem and the source code

我将我的 datepicker 更新为 jQuery UI Datepicker 1.8.11...它仍然在 IE 8 中不起作用!日期选择器弹出得很好,但没有事件从中触发.我的意思是没有点击...没有任何反应...

I updated my datepicker to jQuery UI Datepicker 1.8.11...still it just doesn't work in IE 8! The date-picker pops up just fine, but no event fires from it. I mean no click...nothing happens...

有什么想法吗?

推荐答案

嘿,我不知道你是否已经解决了那个问题,但是问题在于任何添加的属性.特别是如果您正在使用:

Hey I don't know if you have solved that problem yet, however the problem is with any added attributes. Especially if you are using:

yearRange: '-100:+10'

例如...

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

This is how you resolve the issue: copied from http://satish.name/?p=19

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

jQuery datepicker adds a new attribute to the DOM element in IE. if you try to add a new DOM element dynamically copying from an existing element the datepicker will not work in IE as the newly added DOM element refers to the old jQuery attribute. One way to fix this is to delete the attribute and then instantiate the datepicker class on the element. See the following code for the fix.

//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');
})

干杯

这篇关于jQuery 日期选择器在 IE8 中遇到问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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