remoteField
The remoteField tag and other Ajax related tags have been deprecated and will be removed from a future version of Grails. Applications may provide their own Ajax tags and/or Javascript plugins may provide Ajax tags of their own.
Purpose
Creates a text field that sends its value to a remote link when it changes. By default the parameter name sent is called 'value', this can be changed by specifying a 'paramName' attribute.
Examples
Example controller for an application called "shop":
class BookController {def changeTitle() { def b = Book.get(params.id) b.title = params.value b.save() } }
Example usages for this controller:
<g:remoteField action="changeTitle" update="titleDiv" name="title" value="${book?.title}" /><div id="titleDiv">I'm updated with the new title!</div>
Description
This tag creates an input field that fires an AJAX request when its value changes (typically when the user presses return inside the field). The exact Javascript used to fire off the AJAX request depends on which Javascript library is used. This tag also requires the use of either the <g:javascript/> or <g:setProvider/> tags. See the AJAX section of the user guide to find out more.
Attributes
name
(required) - the name of the fieldvalue
(optional) - The initial value of the fieldparamName
(optional) - The name of the parameter to send to the serveraction
(optional) - the name of the action to use in the link; if not specified the default action will be linkedcontroller
(optional) - the name of the controller to use in the link; if not specified the current controller will be linkedid
(optional) - The id to use in the linkupdate
(optional) - Either a Map containing the elements to update for 'success' or 'failure' states, or a string with the element id to update, in which case failure events would be ignoredbefore
(optional) - The JavaScript function to call before the remote function call. A semi-colon is automatically added so you don't have to provide one yourself in this string.after
(optional) - The JavaScript function to call after the remote function call. A semi-colon is automatically added so you don't have to provide one yourself in this string.asynchronous
(optional) - Whether to do the call asynchronously (defaults totrue
)method
(optional) - The method to use the execute the call (defaults to POST)
Events
onSuccess
(optional) - The JavaScript function to call if successfulonFailure
(optional) - The JavaScript function to call if the call failsonERROR_CODE
(optional) - The JavaScript function to call to handle the specified error code (e.g.on404="alert('not found!')"
)onUninitialized
(optional) - The JavaScript function to call if Ajax fails to initialiseonLoading
(optional) - The JavaScript function to call when the remote function loads the responseonLoaded
(optional) - The JavaScript function to call when the remote function completes loading the responseonComplete
(optional) - The JavaScript function to call when the remote function completes, including any updates
Source