remoteFunction

Purpose

Creates a remote javascript function that can be assigned to a DOM event to call the remote method

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:

$('mydiv').onclick = <g:remoteFunction action="show" id="1" />

Example as a method call in GSP only:

<select onchange="${remoteFunction(action:'bookByName',update:[success:'great', failure:'ohno'], params:'\'bookName=\' + this.value' )}">
    <option>first</option>
    <option>second</option>
</select>

Example changing the asynchronous option to false:

<select from="[1,2,3,4,5]" onchange="${remoteFunction(action:'bookByName', update:[success:'great', failure:'ohno'], options=[asynchronous:false]}" />

Description

Attributes

Events

Source

Show Source