remoteLink

用途

当点击的时候,创建一个链接调用远程的函数

示例

在 "shop"应用程序中的一个contrller:

class BookControlller {
     def list = { 
	    [ books: Book.list( params ) ] 	
	 }
     def show = { 
	    [ book : Book.get( params['id'] ) ]      
     }
     def bookByName = { 
	     [ book : Book.findByName( params.bookName ) ] } 
	 }

controller的使用方法:

<g:remoteLink action="show" id="1">Test 1</g:remoteLink>

<g:remoteLink action="show" id="1" update="[update:'success',failure:'error']" on404="alert('not found');">Test 2</g:remoteLink>

<g:remoteLink action="show" id="1" update="success" onLoading="showSpinner();">Test 3</g:remoteLink>

<g:remoteLink action="show" id="1" update="success" params="[sortBy:'name',offset:offset]">Test 4</g:remoteLink>

在GSP调用的方法:

my link = <%= remoteLink( action:'show', id:1,
  update:'success', onFailure:'showError();' ) 
  { "this is the link body" } %>

描述

属性

事件

来源

Show Source