Load Partial Template Ajax - With Grails

浪尽此生 提交于 2019-12-07 05:34:47

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/5345281/load-partial-template-ajax-with-grails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!