Sending views down via ajax


I’ve got a button that opens up a lightbox which requests the form to create a new post, it displays it in the lightbox.

One of the fields in the form is a Jquery date picker, but because this widget is using cs->registerScriptFile to output the javascript file in the head it doesn’t send the js down with the form.

Whats the best way to go about this? Just manually put the script file into the inital page that loads up (the one with the button to open the form) or is there a more clever way of sending the Datepicker js file down with the rest of the ajax form?


I think you can put registerScriptFile on the form. When you are displaying via ajax do you use renderPartial? If so, does the fourth parameter set true? Maybe this can solve your problem

$this->renderPartial('some-view', $parameters, false, true);

Just after I posted the message I stumbled onto that

Seems to have done the trick thanks!