CForm->render() + JuiDatepicker + Ajax

I’m updating a form via an ajax response and this breaks my JuiDatepicker functionality. Any ideas why?

Here is the flow:

  1. User clicks button initiated ajax call

  2. Controller looks up record and builds form using CForm

  3. Controller sends HTML using CForm->render()

All the fields update as I would expect but when I click on the field which is supposed to bring up the JuiDatepicker it no longer works.

Thanks for your help!

$(’#idofdatefield’).datepicker(); // This is needed because this page is loaded through ajax.

In your ajax you need to include this in a script that will be run. I typically put it in a script tag.

I think this is needed because this initialization isn’t run when the form is loaded through ajax. This function sets up the field as a JUI datepicker.