(Quick Reference)

6.7.2 用Prototype实现Ajax - Reference Documentation

Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith

Version: null

6.7.2 用Prototype实现Ajax

Grails features an external plugin to add Prototype support to Grails. To install the plugin type the following command from the root of your project in a terminal window:

grails install-plugin prototype

This will download the current supported version of the Prototype plugin and install it into your Grails project. With that done you can add the following reference to the top of your page:

<g:javascript library="prototype" />

If you require Scriptaculous too you can do the following instead:

<g:javascript library="scriptaculous" />

Now all of Grails tags such as remoteLink, formRemote and submitToRemote work with Prototype remoting.

Grails通过一个外部插件来提供对 Prototype 的支持。要安装此插件,在字符终端的窗口中,进入你工程的根目录,输入下面命令即可:

grails install-plugin prototype

插件将为你下载当前支持的Prototype版本,并且安装到你的Grails工程中。此后你就可以在你页面的开头添加如下的引用即可:

<g:javascript library="prototype" />

如果你需要 Scriptaculous 的话,请使用如下方式:

<g:javascript library="scriptaculous" />

现在所有Grails的Ajax标签比如remoteLinkformRemotesubmitToRemote都使用Prototype来工作了。