Load data from multiple controllers?

I’m creating an web application that need to have fast response time for each click, so the user experience is as good as possible. Doing a postback or callback for each button clicked is too slow. I have had some different ideas how to accomplish this and I it is ok to have a higher initial load time, but not sure how to do this best.

One of my ideas is to load as much as possible of the data on the initial load and just show/hide divs when the user click the menu. If the data is to old I would refresh it with an ajax callback. The idea seems ok, but now sure how to accomplish this. I would prefer being able to separate my code into different controls or else I will get one huge controller, and that can be messy.

Would it be possible not load <?php echo $content; ?> in the layout file and just call each controller/action I need separately from the layout file and hide them? If so what would be the command to call the controller/action from the layout file. Or should I actually drop $content but load all data as widgets? But if so would it be possible to reload the widgets with an ajax callback?

I have multiple other ideas, but many are a bit far fetched :wink:

Do any one have some of the answers or some totally different suggestions? :slight_smile:


To omit layout you can call renderPartial() instead of render().

I’m also not sure this additional complication worth implementing. If you consider there are still users who have their javascript engine turned off, you have to create a non-ajax interface first, and then add inline loading capabilities later.

By the way, welcome to the forums. :)

Thanks for the response (and welcoming me :-)).

I’m aware of the renderPartial and use it a lot, but that do not solve my problem. Because I still need to actually render many control/actions on the initial load.

Regarding the people that have turned off their JavaScript… to be honest, I do not want them as visitors. Just like all IE6 users :wink: So that is not a major concern. My biggest concern is the speed. I would really like to find a way to get max response time of each user action. JavaScript seems to be the way to go, just not sure how to implement it best in Yii.