Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery datepicker keeps reopening in IE

jQuery's datepicker keeps reopening after clicking on a date in IE 8, even on their demo page:

http://jqueryui.com/demos/datepicker/

Does anyone know how to fix this? I don't know about the demo page, but I am having the exact same problem with jQuery 1.6.2 and jQuery UI 1.8.15.

Also, setting the minDate and maxDate options does not seem to have any effect in IE 8. The above seems to also be true with IE 7.

like image 952
Jean-François Beauchamp Avatar asked Aug 16 '11 20:08

Jean-François Beauchamp


4 Answers

The following resolved this issue for me (using jQuery 1.7.2 / jQueryUI 1.8.20)

var $input = $('#date');

$input.datepicker({
  /* 
   * your other settings here 
   */
  onSelect : function() { $input.blur(); },
  onClose  : function() { $input.change(); }
});

$input.on('change paste', function(evt) {
  // process new date input here
});
like image 75
Cory Martin Avatar answered Nov 01 '22 10:11

Cory Martin


1.8.14 works fine in IE8.

The re-opening seems to be a bug in 1.8.15, see broken demo.

like image 40
andyb Avatar answered Nov 01 '22 09:11

andyb


I had the same issue with IE8 and the customized min version of Jquery UI 1.8.16 (all options selected) When I used the full released version of 1.8.16 the problem went away.

like image 1
BuildFailure Avatar answered Nov 01 '22 09:11

BuildFailure


We are facing the same problem for jquery ui 1.11.2. The following snippet solved the problem in our case:

var input = $('<input>');

input.datepicker({
  onSelect: function() {
    this.lastShown = new Date().getTime();
  },
  beforeShow: function() {
    var time = new Date().getTime();
    return this.lastShown === undefined || time - this.lastShown > 500;
  }
});
like image 1
Stefan Zugal Avatar answered Nov 01 '22 10:11

Stefan Zugal