remoteLink

Purpose

Creates a link that calls a remote function when clicked

Examples

Example controller for an application called shop:

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

Example usages for above 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>

As a method call in GSP:

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

Description

Attributes

Events

Source

Show Source