There isn't remoteDiv tag in Grails but in five minutes I've got my tag:
def remoteDiv = { attrs,body ->
def complete = ""
if(attrs.onComplete){
complete = ",onComplete: ${attrs.onComplete}"
}
out << """
<script type="text/javascript">
new Ajax.Updater(
{ success: '${attrs.id}' },
'${attrs.url}',
{
method: 'get',
evalScripts: true
${complete}
});
</script>
"""
}
An example of use:
<div id="testAjax"></div>
<g:remoteDiv
id="testAjax"
url="${createLink(action: 'show', id:'1')}"
onComplete="new Effect.Highlight('testAjax')"
/>
I've use prototype AjaxUpdater to do asynchronous request, it's not library agnostic like others remote tags in Grails but it's simple :D
No comments:
Post a Comment