Last updated by admin 3 years ago
?? - remoteFunction
?? Description
Creates a remote javascript function that can be assigned to a DOM event to call the remote method ?????????????DOM????????????????javascript ???????????????? Parameters
- action (??) - ?????????????????????????????????????????the name of the action to use in the link, if not specified the default action will be linked
- controller (??) - ???????????????????????????????????????????the name of the controller to use in the link, if not specified the current controller will be linked
- id (??) - ????????id?The id to use in the link
- update (??) - 'success' ??'failure'????????????Map???????????failure?????????Either a map containing the elements to update for 'success' or 'failure' states, or a string with the element to update in which cause failure events would be ignored
- before (??) - ????????????????????????javascript????????The javascript function to call before the remote function call
- after (??) - ?????????????????????????javascript????????The javascript function to call after the remote function call
- asynchronous (??) - ????????????????(??????true)?Whether to do the call asynchronously or not (defaults to true)
- method (??) - ??????????????(?????? "post") The method to use the execute the call (defaults to "post")
???? Events
- onSuccess (??) - ?????????????javascript????????The javascript function to call if successful
- onFailure (??) - ????????????????javascript????????The javascript function to call if the call failed
- on_ERROR_CODE (??) - ???????????????????????javascript???????(? on404="alert('not found!')")?The javascript function to call to handle specified error codes (eg on404="alert('not found!')")
- onUninitialized (??) - Ajax??????????????????????????javascript????????The javascript function to call the a ajax engine failed to initialise
- onLoading (??) - ?????????????????javascript????????The javascript function to call when the remote function is loading the response
- onLoaded (??) - ?????????????????????javascript????????The javascript function to call when the remote function is completed loading the response
- onComplete (??) - ???????????????????????javascript??????????????????????The javascript function to call when the remote function is complete, including any updates
? Examples
Example controller for an application called "shop": "shop"??????????????????????????class Book {
def defaultAction="list"
def list = { [ books: Book.list( params ) ] }
def show = { [ book : Book.get( params['id'] ) ] }
}$('mydiv').onclick = <g:remoteFunction action="show" id="1" /><select onchange="${remoteFunction(action:"myaction",update:[success:"great", failure:"ohno"])}"> <option>first</option> <option>second</option> </select>



