Loading Another Widget In Sidebar (With Ajax)

I have a site with main content area and a sidebar.

I wonder, how can I make the following behavior:

In the sidebar is a list of other widgets.

What is the best method to unload the listWidget and load the selectedWidget to the sidebar, when the user clicks one link in the listWidget?

Hi heal,

If I understand correctly your question, you can use the following (with jQuery):


[*]Bind a click event to the items in the list.

[*]When the event fires, you make an AJAX request to the route of the corresponding selected widget (or a common route with a parameter indicating the widget).

[*]The action will return the HTML for the widget only.

[*]You receive this data on the success callback function and insert it in a holder element in your document.

[*]Hide the widget list.


Thank You, Rodrigo!

I thought it can be made with renderPartial, or some simpler way, but this is good for me also.

Yes, you can use CController::renderPartial!