0

This is the "main" code I'm using;

$(function(){
    var initDatepickers = function(){
            var $entrada = $('#form-disponibilidad [name=llegada]');
            var $salida = $('#form-disponibilidad [name=salida]');
            $entrada.datepicker({
                'onSelect': function (str, obj) {
                    var tmpDateObj = $entrada.datepicker('getDate');
                    /* Actualizar selects */
                    $(this).datepicker("hide");
                },
                'minDate': 1,
                showOn: "button",
                buttonImage: "http://next.cabauhotels.com/img/iconos/pixel.png",
                buttonImageOnly: true,
                dateFormat: 'yy-mm-dd'
            });
            $salida.datepicker({
                'onSelect': function () {
                    var tmpDateObj = $salida.datepicker('getDate');
                    datepickerToselect(tmpDateObj,'end');
                    $(this).datepicker("hide");
                },
                'minDate': 2,
                showOn: "button",
                buttonImage: "http://next.cabauhotels.com/img/iconos/pixel.png",
                buttonImageOnly: true,
                dateFormat: 'yy-mm-dd'
            });

        }

        initDatepickers();
});

http://jsfiddle.net/zW3AU/6/

the problem is that after selecting a date, the calendar is never hidden in IE8

I see this error in the console:

enter image description here

Any idea how to solve this and keep the input hidden?

-EDIT-

I found this workaround

if($.browser.msie && parseInt($.browser.version,10) < 9){
      $('#ui-datepicker-div').hide();
}else{
      $(this).datepicker("hide");
}

But it would be great to prevent errors in console, any thoughts?

Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378
  • sorry Toni, i was referring to your jsfiddle, saw it now in your error log. BTW, using jquery 1.8 in jsfiddle on IE8 emulated, i'm unable to reproduce your issue – A. Wolff Dec 16 '13 at 12:44
  • @A.Wolff Right, I made the jsfiddle a bit quickly and just realised the versions won't match – Toni Michel Caubet Dec 16 '13 at 12:47
  • possible duplicate of [Jquery datepicker popup not closing on select date in IE8](http://stackoverflow.com/questions/1704398/jquery-datepicker-popup-not-closing-on-select-date-in-ie8) – Liam Dec 16 '13 at 14:00
  • @Liam If you read the answer, this seems to have stopped working.. – Toni Michel Caubet Dec 16 '13 at 15:15
  • I was thinking [this more complete answer](http://stackoverflow.com/a/1975858/542251) – Liam Dec 16 '13 at 15:41

1 Answers1

0

I found this workaround

if($.browser.msie && parseInt($.browser.version,10) < 9){
      $('#ui-datepicker-div').hide();
}else{
      $(this).datepicker("hide");
}
Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378