rhinds
rhinds

Reputation: 10043

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!

Upvotes: 5

Views: 2524

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

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.

Upvotes: 4

Related Questions