简体   繁体   English

Grails AJAX标签

[英]Grails AJAX Tags

Grails has a few of these tags that I'm highly skeptical about. Grails对此有些怀疑,我对此表示高度怀疑。

<g:remoteLink action="show" id="1" update="success" onLoading="showProgress();">
    Show Book 1
</g:remoteLink>

This gives me this garbage on the page: 这给了我页面上的垃圾:

 <a href="/show/1" onclick="new Ajax.Updater('success','/show/1',{asynchronous:true,evalScripts:true,onLoading:function(e){showProgress();}});return false;">Show Book 1</a>

What is the consensus on using these? 使用这些的共识是什么?

I am not too fond of these tags myself, but they have the advantage of making your GSP pages independent from your ajax implemetation. 我自己不太喜欢这些标签,但是它们具有使GSP页面独立于ajax实现的优点。

I am not sure though why you call this garbage. 我不确定您为什么称其为垃圾。 It is an implementation of an ajax update using prototype. 它是使用原型进行ajax更新的实现。 If you do not like the syntax, you can change the ajax library used by the grails tag by adding the following tag to your page (or global layout) 如果您不喜欢该语法,则可以通过在页面(或全局布局)中添加以下标记来更改grails标记使用的ajax库

<g:javascript library="yui" />

for Yahoo UI 对于Yahoo UI

or 要么

<g:javascript library="dojo" />

for dojo 为道场

The resulting javascript will look different, but it will still result in a line of javascript being outputted to your page to support your ajax call. 生成的javascript看上去会有所不同,但是仍然会导致一行javascript输出到您的页面以支持您的ajax调用。

If you do not like it, you can do like me and write it yourself instead of using the grails tags. 如果您不喜欢它,则可以像我一样自己写,而不用使用grails标记。 I have so much javascript to write anyways that using these tags is kind of useless. 无论如何,我有很多javascript要写,使用这些标签是没用的。

I personally find JQuery to be the easiest library to work with for page interaction and ajax. 我个人发现JQuery是最容易与页面交互和Ajax一起使用的库。 But this is my personnal taste. 但这是我的个人品味。

Regards, 问候,

Vincent Giguère VincentGiguère

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM