开发者

Jquery datepicker button disappear with localization

I'm using Jquery datepicker with Spanish & French. It works except that the button next to the date field di开发者_Python百科sapear when I switch to either French or Spanish, it comes back when I switch to English. here is my code:

$(function () {
    var loclanguage = $("#ddlLanguages").val().substr(0, 2);
    $.datepicker.setDefaults($.datepicker.regional['']);
    if (loclanguage == 'es') {
        $(".datepicker").datepicker($.datepicker.regional['es']);
    } else if (loclanguage == 'fr') {
        $(".datepicker").datepicker($.datepicker.regional['fr']);
    } else {
        $.datepicker.setDefaults($.datepicker.regional['']);
    }
    $("#ddlLanguages").change(function () {
        $(".datepicker").datepicker("option", $.datepicker.regional[$(this).val()]);
    });
});

$(".datepicker").datepicker({
    showOn: "button",
    showAnim: '',
    buttonImage: "../images/bouton-calendrier.png",
    buttonImageOnly: true,
    dateFormat: 'yy-mm-dd'
});

It behave the same in IE 8, FF 3.6, Chrome 12.0

Thanks


After many tries I made it work. the trick is to set my datepicker options for all datepickers before setting the regional like this:

$(function () {

   *$.datepicker.setDefaults({
     showOn: 'both',
     buttonImageOnly: true,
     buttonImage: '../images/bouton-calendrier.png',
     dateFormat: 'yy-mm-dd'
   });*

  var loclanguage = $("#ddlLanguages").val().substr(0, 2);
  $.datepicker.setDefaults($.datepicker.regional['']);
  if (loclanguage == 'es') {
     $(".datepicker").datepicker($.datepicker.regional['es']);
  } else if (loclanguage == 'fr') {
     $(".datepicker").datepicker($.datepicker.regional['fr']);
    } else {
     $.datepicker.setDefaults($.datepicker.regional['']);}

 $("#ddlLanguages").change(function () {
    $(".datepicker").datepicker("option", $.datepicker.regional[$(this).val()]);
 });
});

then I just associate the datepicker to my class

 $(".datepicker").datepicker();

And it work! thank you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜