Grails Load r:require [英] Grails Load r:require
问题描述
在我的ApplicationResources.groovy中,我有
modules = {
common {
dependsOn(' jquery')
资源url:'js / jquery.datetimepicker.js'
资源url:'css / jquery.datetimepicker.css'
}
}
并且我的index.gps在头部有这个
< r:require modules =common/>
在我的layout.gsp中:
< R:layoutResources />
但它给了我这个错误: Uncaught TypeError:Object [object Object]在我使用时没有方法'datetimepicker'
< script>
$('#datetimepicker')。datetimepicker();
< / script>
另一个错误是当我使用它看起来像缺少一些调用到r:layoutResources标记。在渲染你的页面后,下面的内容还没有被渲染出来:[defer]
:
< r:脚本>
$('#datetimepicker')。datetimepicker();
< / r:script>
我对r:script vs脚本感到困惑。有什么我失踪?当我检查时,只加载jquery和css。
您需要 2 单独在你的布局GSP中的< r:layoutResources />
的实例,就在< / head>
另一个就在< / body>
之前。第一个将使用头部处置来呈现资源,第二个将渲染那些带有延迟的资源。
由于 layoutResources
标签位于头部/正文的末尾,所产生的脚本标签或CSS链接将出现在您定义的任何纯文本< script>
之后。但是< r:script>
将排队输出到< r:layoutResources />
在之后提供了< r:require>
所请求的资源。
In my ApplicationResources.groovy I have
modules = {
common {
dependsOn('jquery')
resource url: 'js/jquery.datetimepicker.js'
resource url: 'css/jquery.datetimepicker.css'
}
}
And my index.gps have this in the head
<r:require modules="common"/>
In my layout.gsp:
<r:layoutResources/>
But it's giving me this error: Uncaught TypeError: Object [object Object] has no method 'datetimepicker'
when I use
<script>
$('#datetimepicker').datetimepicker();
</script>
and another error is when I use It looks like you are missing some calls to the r:layoutResources tag. After rendering your page the following have not been rendered: [defer]
:
<r:script>
$('#datetimepicker').datetimepicker();
</r:script>
I'm confused about r:script vs script. Is there anything I'm missing? When I'm inspecting, only load the jquery and the css.
You need two separate instances of <r:layoutResources/>
in your layout GSP, one just before the </head>
and the other just before the </body>
. The first one will render resources with "head" disposition, the second will render those with "defer".
Since the layoutResources
tags go at the end of the head/body, the resulting script tags or CSS links will appear after any plain <script>
you define. But <r:script>
will queue up to be output by <r:layoutResources/>
in the appropriate disposition, after it has rendered the resources requested by <r:require>
.
这篇关于Grails Load r:require的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!