views:

22

answers:

1

Hi all,

I have a lot of JQuery DatePicker's in my application. How can I set to all this elements default settings/options?

$(function() {
        $( "#<%=dtIncident2.ClientID %>" ).datepicker({
            showOn: "button",
            buttonImage: "AppData/Images/calendar.gif",
            buttonImageOnly: true,
            showWeek: true,
            firstDay: 1,
            dateFormat: 'dd-mm-yy',
            maxDate: '+0',
            regional: 'uk'
        });
    });

I don't want to set every time showOn, buttonImage, buttonImageOnly... and other options.

+2  A: 

did you even search for the answer before you asked? :P

http://docs.jquery.com/UI/Datepicker/setDefaults

$.datepicker.setDefaults({
   showOn: 'both',
   buttonImageOnly: true,
   buttonImage: 'calendar.gif',
   buttonText: 'Calendar' });

it's the first result when you google jquery ui datepicker set defaults.

Patricia