Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load Partial Template Ajax - With Grails

I am creating a grails webapp, and have the main index gsp, and there are several common components that will be common across most of the pages on the site that I am using partial templates for.

Each partial template will be quite isolated and contain very different information, so each one should be getting info from different controllers.

What I want is on page loading, for each partial template to make a call to a controller to load the required content - Im hoping there is some tag I can easily place in my partial templates specifying a controller/action that will automatically call the controllers on load.

Is this possible?

----EDIT-----

Also, one of the partial templates' controllers will be pulling back information from a web service that can take some time, so it would be good if i could also load these templates asynchronously..

Thanks!

like image 558
rhinds Avatar asked Oct 12 '22 12:10

rhinds


1 Answers

That's what the <g:include> Tag is for. It's very useful by itself but even more if combined with the springcache plugin and using page fragment caching. Since the include calls a regular action in a controller you can also consume it by an ajax call.

like image 179
Stefan Armbruster Avatar answered Oct 15 '22 10:10

Stefan Armbruster