I have the following g:render tag in a gsp page:
<g:render template="/artist/rate" model='[artistID: 1, rating: 5]' />
In the _rate template I render a star rating plugin by RichUI:
<div id="artist${artistID}">
<richui:rating dynamic="true" id="${artistID}" units="5" rating="${rating}" controller="rating" action="rate" />
</div>
What I need is to be able to change the "model" attribute dynamically on run time. I tried a very naive solution in which used JQuery to change the attributes. Something like this:
$(g:render).attr('model','[artistID: 1, rating: 3]')
but soon I realized that it does not work because the html generated from the gsp page does not contain the g开发者_运维百科:render tag, as it is replaced when the plugin is rendered.
Is there any way to achieve this? Thanks very much.
You need a controller to figure out what the values of the model you want to render is and then pass that, the updated/changed model, to the gsp render tag.
The controller should be responsible for passing the correct model to the view, so do it there.
精彩评论