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.
精彩评论