开发者

jquery ui datepicker IE reload or jumps to the top of the page

I am noticing this issue in IE 7 + 8

$('#event-start-date').datepicker({dateFormat:'DD MM dd开发者_如何学编程 yy',minDate:'-0d'});

When you pick the date in IE 7 or 8 the page goes to # and reloads the root page

I am using jquery 1.4.0 and ui 1.7.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.

I found a fix that is workable if not desirable here: http://forum.jquery.com/topic/modal-dialog-with-datepicker

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

Took me a while to find this because of the many other issues with jquery datepickers and IE, go figure.


I have the same problem with FF 3.6.13, Jquery 1.5.0 delivered from the jquery CDN and jqueryui 1.8.9.

Extremely oddly, its only happening on SOME computers with the same version of firefox, with caches cleared.

This fix worked for me though. i.e.

$(".datepicker").datepicker({
  dateFormat: "yy-mm-dd",
  changeMonth: true,
  changeYear: true,
  numberOfMonths: 2,
  showButtonPanel: true,
  onSelect: function() {
    $(".ui-datepicker a").removeAttr("href");
  }
});

The only issue is it now ignores the .change event. I fixed this by adding $(this).change():

$(".datepicker").datepicker({
  dateFormat: "yy-mm-dd",
  changeMonth: true,
  changeYear: true,
  numberOfMonths: 2,
  showButtonPanel: true,
  onSelect: function() {
    $(".ui-datepicker a").removeAttr("href");
    $(this).change();
  }
});

$(".date_unix").datepicker({
  dateFormat: "@",
  changeMonth: true,
  changeYear: true,
  numberOfMonths: 2,
  showButtonPanel: true,
  onSelect: function() {
    $(".ui-datepicker a").removeAttr("href");
    $(this).change();
  }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜