ajax - Grails - Select box tied to object ID and remote field -
run bit of odd problem increasingly frustrating
scenario: have list of domain objects, each has g:select attached rendered remote field.
how tie status variable or personinstance id selection box, when use renderfield, update testdiv_(number)
view:
<g:each in="${listofpeople}" status="i" var="personinstance"> <td> text: <g:remotefield action="getresults" controller="person" id="" update="testdiv_${personinstance.id}" paramname="search" name="getresults" value="" /> <g:each in ="${personinstance?.choices}" var="choice" status="x"> <li>${choice}</li> </g:each> </td> <td> <g:render template="renderthistemplate"></g:render> </td> </g:each> template:
<div id="testdiv_${personinstance.id}" class="testdiv_${personinstance.id}"> <g:select id="achoice" name="achoice.id" from="${allchoices}" optionkey="id" value="" /> <g:actionsubmit action="addchoice" value="add"/> </div> edit
i know remote call (ajax) passing update testdiv_(number). problem template id , assigning value template div.
just incase needs answer in future. apparently cannot reference instance variable (personinstance) in g:each template.
so replaced g:render code , worked:
<g:each in="${listofpeople}" status="i" var="personinstance"> <td> text: <g:remotefield action="getresults" controller="person" id="" update="testdiv_${personinstance.id}" paramname="search" name="getresults" value="" /> <g:each in ="${personinstance?.choices}" var="choice" status="x"> <li>${choice}</li> </g:each> </td> <td> <div id="testdiv_${personinstance.id}" class="testdiv_${personinstance.id}"> <g:select id="achoice" name="achoice.id" from="${allchoices}" optionkey="id" value="" /> <g:actionsubmit action="addchoice" value="add"/> </div> </td> </g:each>
Comments
Post a Comment