jQuery UI Datepicker regional language and max value
I'm trying to co开发者_运维问答mbine some options of jQuery UI Datepicker
I'm using the code below:
$("#<%=tStartDate.ClientID %>").datepicker($.datepicker.regional['tr']);
I need to add option for max date which is:
{ maxDate: '+1m +1w' }
Can anybody tell how to add this parameter?
I think you want this:
$.datepicker.setDefaults($.datepicker.regional['tr']);
$("#<%=tStartDate.ClientID %>").datepicker( { maxDate: '+1m +1w' } );
Seeing that this question shows up first on google and while the answer given is adequate - a more complete answer can be formulated with info taken from other sources deeper in the google results.
While one can set the defaults as above, you should be be aware that the individual regional files do set the default when loaded so the last one loaded has effect unless you change it when initializing your datepicker.
The $.datepicker.regional['tr'] returns an object and your options is an object so they can be merged together.
$("#<%=tStartDate.ClientID %>").datepicker($.extend(
{},
$.datepicker.regional['tr'] || $.datepicker.regional[''],
{ maxDate: '+1m +1w' }
));
Why the
$.datepicker.regional['tr'] || $.datepicker.regional['']
Because the last loaded language might have set the default and the $.datepicker.regional['tr'] might return undefined but $.datepicker.regional[''] will always return english - marginally better than Welsh or Zulu :-)
精彩评论