Ajax Response contains jQuery/widgets-- how?

Hello,

I have a form with some widgets on it. One is an autocomplete, another is a multiselect box. I would like to load the form with an ajaxLink. But when the form loads, the jQuery code does not work because the widgets rely on the ready() function to attach the jQuery code. Is there a way to create widgets so that they behave properly when loaded through ajax?

Thanks,

Greg

Hi,

I had the same problem. I solved it for now but still looking for better solution.

I copied Autocomplete code (which Yii generates at not-ajax page), removed ready() function and created my own. When form is loaded by ajax request I just call my function which creates Autocomplete widget. I also should include Autocomplete js and css files manually.

Would like to find more elegant solution though.

Thanks

I think I found the solution. renderPartial() has a processOutput flag. If this is set to true, then the script is included so that it runs after an ajax load. I tried it and the autocomplete on my ajax-loaded form worked perfectly.

Greg

Hi guys!!

The solution of Gsatir works perfectly, but has one side effect: after reloading the ClientScript code OUTSIDE the form loaded will not work.

That is still an open issue and we are all waiting for a solution.

Personally, I use the same solution of gstar and I pay attention to reload all clientScirpted widgets.

Take a look at this post