【问题标题】:Plugin missing while using ajax prototype in Grails 2?在 Grails 2 中使用 ajax 原型时缺少插件?
【发布时间】:2012-10-07 20:18:11
【问题描述】:

你好..我正在使用 Grails 2 并尝试实现从 gsp 页面到我的控制器的 ajax 调用..首先 grails 2 中缺少库原型我使用命令 grails install-plugin prototype 解决了这个问题..现在错误没有出现但无法正常工作,并且出现了不同的错误..

我在这里附上了代码..如果我更改第一个,我正在尝试简单更新第二个选择框

我还在 Config.groovy 中添加了 grails.views.javascript.library = "prototype" 这一行

<code>
     //Controller<br>
        def ajaxgetStrudents() {

            def college=College.get(params.id)
            render college?.students as JSON

        }
        //GSP<br>
        javascript library="prototype" plugin="prototype"<br>
        <g:select id="name" name="name" from="${collegeNames.name }"  
        onChange="${ remoteFunction(controller:'College', action:'ajaxgetStrudents', 

        , onComplete: 'updateStudent(e)',params   :'\'id=\'+this.value '        

            )}
`</code>

我编写了 javascript 代码来填充学生选择框..此代码不起作用..在控制台中出现这样的错误

` Error 2012-10-08 01:16:57,933 [http-bio-8083-exec-6] ERROR [/SampleGrails].[default] - Servlet.service() for servlet [default] in context with path [/SampleGrails] threw exception Message: It looks like you are missing some calls to the r:layoutResources tag. After rendering your page the following have not been rendered: [defer] Line | Method ->> 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor


| 603 |在 java.util.concurrent.ThreadPoolExecutor$Worker 中运行 ^ 722 |跑步 。 . .在 java.lang.Thread `

首先我想运行这段代码..??

接下来,即使我安装了未添加到我的项目插件文件夹中的原型插件..但它显示在 grails list-plugin -installed 命令中..为什么它是..??

谢谢..,

【问题讨论】:

    标签: ajax prototype grails-plugin grails-2.0 grails-controller


    【解决方案1】:
    1. 从 Grails 2.1.0 开始,原型已被删除(不确定 2.0.3)

    替换

    <g:javascript library="prototype" plugin="prototype" />
    

    <g:javascript library="prototype" plugin="prototype" />
    <r:layoutResources/>
    

    希望对您有所帮助。始终参考可用的文档。这是一个升级 grails 的链接,虽然有很多信息 Grails 2.1.x

    【讨论】:

    • 感谢您的回答,我正在使用类似的 javascript,我添加了 r:layoutResources 它根本不起作用。也感谢您的文档链接我在这里没有尝试任何升级..问题是即使在我安装了原型插件之后我也无法在 Grails 2 中访问它..我想知道如何做到这一点..

      谢谢..,
    【解决方案2】:

    在 grails 2.x 中安装插件的正确方法是在 BuildConfig.groovy 中放置一个条目,而不是“安装插件”命令。

    为了排除故障,您可以在 Firefox 中尝试“Firebug”,看看是否正在加载原型脚本。

    【讨论】:

      【解决方案3】:

      标题 ## - 列表项

      我对原型有同样的问题,无法在我的 grails 应用程序中包含prototype.js。基本上我同时使用 jquery 和原型,并使用以下 sn-ps 包含库。

      `

      问题是 gsp 无法加载原型插件,因为我的原型 ajax 无法正常工作并出现以下异常。

      渲染您的页面后,以下内容尚未渲染:[defer] Line |方法->> 1110 | java.util.concurrent.ThreadPoolExecutor中的runWorker

      【讨论】:

        【解决方案4】:

        我认为您只是错过了 remoteFunction 调用中的“update”属性。

        【讨论】:

          猜你喜欢
          • 2011-12-24
          • 1970-01-01
          • 2013-04-12
          • 2019-02-15
          • 1970-01-01
          • 2015-06-12
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多