Grails 3.0< g:remoteLink ...>由于弃用Ajax调用替换 [英] Grails 3.0 <g:remoteLink ...> Ajax call replacement due to deprecation

查看:107
本文介绍了Grails 3.0< g:remoteLink ...>由于弃用Ajax调用替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Grails 3.0.0 M1指出g:remoteLink不推荐使用,在3.0.1中它不再存在于g:命名空间中。文档中没有任何建议替代此功能。是否有人请用GSP文件的替换选项作出响应,以使用Prototype JavaScript库执行控制器操作?如果可能的话,是否会使用Groovy自定义标签库来直接在GSP文件中删除嵌入的代码?解决方案

标签使用嵌入HTML标签的嵌入式JavaScript,这一直被认为是不好的做法。与此同时,用于创建与jQuery等JavaScript框架的远程链接的API已经发展到使用它们同样简单的程度,并且它们的优点是静态资源可以通过资产管道和应用程序进行优化如果考虑到过去几年的情况如何变化,Grails团队决定弃用这些标签,因为它们不再被认为是最佳实践,而且您更好关闭使用原生JavaScript API(jQuery等)作为替代。



原始代码仍可在 https://bintray.com/grails/plugins/ajax-tags



如果你想要它们,你必须声明一个依赖项:

  compile'org.grails.plugins:ajax-tags:1.0.0.RC1'


Grails 3.0.0 M1 states that g:remoteLink is deprecated and in 3.0.1 it no longer exists in the g: namespace. There is nothing in the documentation that suggests replacement of this functionality. Will someone please respond with a replacement option for GSP files to execute a controller action using the Prototype JavaScript library? If also possible, would a solution utilizing a Groovy custom tag library to eliminate embedded code directly in GSP files be presented?

解决方案

The tags use inline javascript embedded into HTML tags which has long been considered bad practise. At the same time the APIs for creating remote links with JavaScript frameworks like jQuery and so on have advanced to the point where it is just as easy to use them and they have the advantage that the static resources can be optimised by asset pipeline and your application will perform better.

So given how things have changed over the last few years the Grails team decided to deprecate the tags as they are no longer considered best practise and you are better off using the native JavaScript APIs (jQuery etc.) as an alternative.

The original tags are still available at https://bintray.com/grails/plugins/ajax-tags

If you want them you have to declare a dependency:

compile 'org.grails.plugins:ajax-tags:1.0.0.RC1'

这篇关于Grails 3.0< g:remoteLink ...>由于弃用Ajax调用替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆