Ajaxlink in controller


I am trying to reload a div in ajax with the following code :

In the view :

In fact the link is working only one time (when rendering into the view), when I call the controller in ajax and try to show the link, it has not action.

I have searched on the forum and saw that some people are using livequery to rebind links.

In my case how can I do that? Is there a better way to handle it?

Thank you

I think you should avoid to have the ajax script inside the section being replaced. Use registerScript or, to begin with, just add the script in the view as I did in my test (no more testing so far). I guess it might be appropriate to use a plain CHtml::link() instead of ajaxLink.

In my test code I first renderPartial the AjaxUpdate.php on loading the view. When "#target a" is clicked I renderPartial AjaxUpdate.php again to replace the content inside the div (thats why I changed replaceWith to html(html).



I actually prefer using jQuery's ajax() function in a small piece of code that you can register with registerScript. Its cleaner, offers more flexibilty, and can be encapsulated inside the view or controller.