Reputation: 137
Can g:formRemote update more than one div in grails, What would be a viable strategy for updating multiple divs? can anyone explain me this with an example...
Upvotes: 0
Views: 1351
Reputation:
Yes you can control the update of your page. Instead of using the update
attribute, use the onSuccess
event.
From the docs:
onSuccess (optional) - The JavaScript function to call if successful
View
<g:formRemote name="myForm" onSuccess="updateBook(data)" method="GET"
action="${createLink(controller: 'book', action: 'show')}"
url="[controller: 'book', action: 'show']">
Book Id: <input name="id" type="text" />
</g:formRemote>
<script type='text/javascript'>
function updateBook(data) {
//do what you want here
}
</script>
Controller
def show() {
//TODO: validate if exists and etc..
def book = Book.get(params.id)
render book as JSON //send JSON to the client, handling in the updateBook function.
}
Upvotes: 2