views:

26

answers:

1

I'm working with a site with the JQuery UI datepicker displayed on a lot of different pages. We have a certain set of features we'd like the date picker to use for all pages - the same date format, the same icon, etc.

What's the best way to set these items as the default for the datepicker() function, rather than have every call to datepicker() include the same options? I'm thinking of either we somehow modify the properties of the datepicker() function or we create our own function that wraps the dataepicker() and sets those defaults.

+2  A: 

You can use $.datepicker.setDefaults() once in a file included on every page (if you have a main .js of some sort for example) that runs before your .datepicker() calls, for example:

$.datepicker.setDefaults({ dateFormat: 'yyyy-mm-dd' }) 

The options are passed in exactly as they would be to a .datepicker() call.

Nick Craver
Thanks! Exactly what I needed. Of course the solution ends up on the very page I linked to in my question!
Jason Gritman