Grails - 更新位于模板中的TD

时间:2012-03-05 21:12:03

标签: grails

我有一个在模板中有列的表:

<div id="petDiv">
            <table>
                <thead>
                    <tr>
                        <g:sortableColumn property="breed" title="${message(code: 'contact.breed.label', default: 'Breed')}" />
                        <g:sortableColumn property="age" title="${message(code: 'contact.age.label', default: 'Age')}" />
                    </tr>
                </thead>
                <tbody>
                    <g:each in="${availablePets}" status="i" var="pet">
                            <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">

                            <td><g:link action="show" id="${pet.id}">${fieldValue(bean: pet, field: "Breed")}</g:link></td>
                            <td>${fieldValue(bean: pet, field: "Age")}</g:link></td>
                            <td>
                                <g:form>
                                    <fieldset class="pDivB">
                                        <g:remoteLink action="updatePet" update="another template here??" params: [] >Update</g:remoteLink>
                                    </fieldset>
                                </g:form>
                            </td>   
                            </tr>
                    </g:each>
                </tbody>
            </table>
</div>

我想:

Hit link
Go to updatePet method in Controller with the ID of that pet
Update my <td> tags for breed and age for that row only

我尝试使用我在线阅读的jQuery / Javascript组合,但它只更新了第一行。

1 个答案:

答案 0 :(得分:0)

我有一些类似的示例代码 - https://github.com/aldrinm/grails-sample-code

希望有所帮助。