jquery ui datepicker IE 重新加载或跳转到页面顶部 [英] jquery ui datepicker IE reload or jumps to the top of the page
问题描述
我在 IE 7 + 8 中注意到这个问题
I am noticing this issue in IE 7 + 8
$('#event-start-date').datepicker({dateFormat:'DD MM dd yy',minDate:'-0d'});
当您在 IE 7 或 8 中选择日期时,页面转到 # 并重新加载根页面
When you pick the date in IE 7 or 8 the page goes to # and reloads the root page
我使用的是 jquery 1.4.0 和 ui 1.7.2
I am using jquery 1.4.0 and ui 1.7.2
推荐答案
我在使用 IE7 的 jquery 1.4.2 中遇到了同样的问题.这仅在使用模式对话框时发生在我身上.日期选择器出现在页面上就好了,但选择一个日期会导致您被重定向到 # 片段.
I've experienced the same issue with jquery 1.4.2 using IE7. This only happens to me when using a modal dialog box. The datepicker appears on the page just fine but selecting a date causes you to be redirected to the # fragment.
我在这里找到了一个可行的修复方法:http://forum.jquery.com/topic/modal-dialog-with-datepicker
I found a fix that is workable if not desirable here: http://forum.jquery.com/topic/modal-dialog-with-datepicker
基本上,您只需在选择时从框中撕下 href 即可:
Basically you just tear the href off of the box on select:
.datepicker({ onSelect: function() { $(".ui-datepicker a").removeAttr("href"); } });
或者,如果您在动态加载和重新绑定的内容上使用日期选择器,您可能必须首先丢失该类:
Or, if you are using the datepicker on content that is dynamically loaded and re-binding you may have to lose the class first:
$("#your_text_box_id").removeClass('hasDatepicker').datepicker({ onSelect: function() { $(".ui-datepicker a").removeAttr("href"); } });
我花了一段时间才找到这个,因为 jquery 日期选择器和 IE 存在许多其他问题,请看图.
Took me a while to find this because of the many other issues with jquery datepickers and IE, go figure.
这篇关于jquery ui datepicker IE 重新加载或跳转到页面顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!