Datepicker problem when I call datepicker() on a div

Datepicker problem when I call datepicker() on a div

When I call datepicker() on a div an I try to localize the calendar it doesn't show the corresponding language until I click in some option of the datepicker. The first time it doesn't work but the next times it does.


  1.       $.datepicker.setDefaults($.datepicker.regional['es']);
  2.       $("#calendarDiv").datepicker({
  3.           changeMonth: true,
  4.           changeYear: true,
  5.           showOtherMonths: true,
  6.           showButtonPanel: true,
  7.           dateFormat: 'yy-mm-dd',
  8.           minDate: '-5y',
  9.           maxDate: '+2y',
  10.           hideIfNoPrevNext: true
  11.       });

But if I call datepicker() on an Input it works perfectly showing the Spanish language since first time I click on the input.