6.7.1.2 更新内容 - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith
Version: null
6.7.1.2 更新内容
This is great, but usually you provide feedback to the user about what happened:GSP code:The above example will call the action and set the contents of the Here the
目前都还不错,但一般来说你会提供一些信息反馈给用户,以告诉都发生过什么,比如:def delete() {
def b = Book.get(params.id)
b.delete()
render "Book ${b.id} was deleted"
}<div id="message"></div> <g:remoteLink action="delete" id="1" update="message"> Delete Book </g:remoteLink>
message div to the response in this case "Book 1 was deleted". This is done by the update attribute on the tag, which can also take a Map to indicate what should be updated on failure:<div id="message"></div> <div id="error"></div> <g:remoteLink update="[success: 'message', failure: 'error']" action="delete" id="1"> Delete Book </g:remoteLink>
error div will be updated if the request failed.
def delete() {
def b = Book.get(params.id)
b.delete()
render "Book ${b.id} was deleted"
}<div id="message"></div> <g:remoteLink action="delete" id="1" update="message"> Delete Book </g:remoteLink>
delete操作,并且将响应内容"Book 1 was deleted"设置到id为message的div中,这是通过标签中的update属性来完成的。此外还可以用Map参数来设定失败时要更新那些,比如:<div id="message"></div> <div id="error"></div> <g:remoteLink update="[success: 'message', failure: 'error']" action="delete" id="1"> Delete Book </g:remoteLink>
error将会被更新。

