Ok, I found a fix, although I don't think it's as elegant as I would
like, but oh well.  Before I was running the init function once and
trying to pass the new date to the datepicker.  Now, I'm running the
init function every time they click one of the links (so I'm able to
run the init function again passing in the defaultDate).  Then when I
close the modal dialog I destroy the date picker.  Works like a charm,
but like I said, not as elegant.

Greg

On Mar 6, 4:13 pm, gregerly <[email protected]> wrote:
> Hello All,
>
> Having an issue setting the date of a datepicker after it's been
> initialized.  I call the init function on page load, and the
> datepicker resides in a hidden div that becomes a modal dialog.  When
> they click on an area of the page the dialog is launched and it's at
> this time that I want to set the date.  Here is some code I'm using to
> try and achieve this, it's not working ,but it's not erroring either.
>
> //THE INIT FUNCTION
>         $('#update_appt_datepicker').datepicker({
>                 showButtonPanel: true,
>                 dateFormat: 'DD MM dd, yy',
>                 altField: '#update_formated_date',
>                 altFormat: 'yy-mm-dd'
>         });
>
> //THEN LATER
>
> $('#appt_list_ul li').click(function(){
>                                                         //get the appt details
>                                                         var cur_date    = 
> $('#edit_formated_date').val(); //2009-03-15
>                                                         var date_pieces = 
> cur_date.split('-');
>                                                         var date_obj    = new 
> Date(date_pieces[0],(date_pieces[1] * 1) -
> 1,date_pieces[2]);
>                                                         
> //date_obj.setFullYear(date_pieces[0],(date_pieces[1] * 1) -
> 1,date_pieces[2]);
>
>                                                         //passin the date to 
> the edit calendar
>                                                         
> $('#update_appt_datepicker').datepicker('option',
> {defaultDate:date_obj});
>
>                                                         //pass in the time
>
>                                                         //open the dialog
>                                                         
> $("#edit_appt_dialog").dialog('open');
>                                                 });
>
> I get the modal popup just fine, however the date picker has the
> current date selected instead of the one I'm trying to pass to it. If
> I alert the date_obj I get the full string of the date, so I know I
> have a workable date object.
>
> Thanks!
>
> Greg
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to