Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery: DatePicker defaults

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.

like image 569
Dumitru Avatar asked Sep 29 '10 14:09

Dumitru


1 Answers

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.

like image 198
Patricia Avatar answered Sep 17 '22 18:09

Patricia