views:

404

answers:

2

In my page, the datepicker dateFormat option is being set automatically by loading a localized .js file according to the current users's language settings. Elsewhere in the page, I need to format some dates, so I'd like to get the dateFormat option back out of the datePicker.

The jQuery documentation says you can retrieve the dateFormat option like so:

$('.selector').datepicker('option', 'dateFormat');

However, this returns a jQuery object wrapping the datePicker, not a string value as expected. Is this a bug? Is there another way to retrieve the dateValue option?

I'm using jQuery 1.3.2 and jQuery UI 1.7.1.

I know that I could simply look up the dateFormat another way, but pulling it out of the datepicker would be clean and elegant.

+1  A: 

Using that method works for me1. Are there multiple items with the selector class? Do you know that the element has already been added as a date picker?


1 On the Date Picker demo site, type javascript:alert($("#datepicker").datepicker('option', 'dateFormat')); into the address bar, and it will give you "mm/dd/yy."

bdukes
Thanks. I noticed the datepicker demo siteis using jQuery-ui 1.7.2. I moved from 1.7.1 to 1.7.2 and everything works perfectly.
ctsears
A: 

and here's the bug report: http://dev.jqueryui.com/ticket/4301

Ovesh