3

I have an input that is using jQuery UI datepicker, upon selecting a date the datepicker closes and then i make an ajax call to get some data back and refresh a datagrid.

Somehow, after the datagrid finishes refreshing the datepicker auto open's. I'm presuming the input never lost focus and there for the datepicker triggers. This only happens in chrome. Is there a way to stop this from happening ?

I've tried forcing .blur() upon closing the datepicker, but that didn't work

$(".datePickerEnable").datepicker({
            dateFormat:"dd-mm-yy",
            changeMonth: true,
            changeYear: true,
            dayNames: [ "Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sabado" ],
            dayNamesMin: [ "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab" ],
            monthNames: [ "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" ],
            onClose: function() {
                this.blur();
            }
        })

Doing document.activeElement after the datagrid refresh shows that the input is still focused.

mfreitas
  • 2,395
  • 3
  • 29
  • 42

2 Answers2

3

On the formUtils.js comment the lines 5736 to 5739.

Diogo Cardoso
  • 21,637
  • 26
  • 100
  • 138
0

Try to set focus to another element using the focus method of jQuery:

$('#target').focus();
Felipe Gavilán
  • 393
  • 2
  • 10