mogoman
mogoman

Reputation: 2298

jQuery localization calling setdefauls vs datepicker()

Can anyone tell me why this happens.

The following code works perfectly, I get the datepicker in German:

<input id="foo" type="text"> pick it
<script>
      $(function() {
        $( "#foo" ).datepicker();
        $.datepicker.setDefaults( $.datepicker.regional[ "de" ] );
      });
      </script>

But the following code doesn't work (I get the datepicker in Japanese):

<input id="foo" type="text"> pick it
<script>
      $(function() {
        $( "#foo" ).datepicker();
        $( "#foo" ).datepicker( $.datepicker.regional[ "de" ] );
      });
      </script>

Here are my include files :

http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js

http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js

http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/i18n/jquery-ui-i18n.min.js

Side note. According to the docs http://jqueryui.com/demos/datepicker/ it should work. Can anyone reproduce this?

Upvotes: 1

Views: 1212

Answers (1)

Irvin Dominin
Irvin Dominin

Reputation: 30993

If you your regional code is not recognized by the plugin it sets japanese... http://jsfiddle.net/IrvinDominin/rGpCE/1/

I reproduce it; you can change your code in this way:

  $(function() {
    $("#foo").datepicker();
    $("#foo").datepicker("option", $.datepicker.regional["de"])
  });

Updated fiddle: http://jsfiddle.net/IrvinDominin/rGpCE/2/

Upvotes: 2

Related Questions