I have a Grails 2.0.0 project that was created using grails create-app
. In my HTML and GSP files, I\'m trying to include jquery.js
. I\'ve tried all of
Currently, in 2015, all you have to do is add runtime ":jquery:1.11.1"
to your BuildConfig.groovy, and that is all.
I found (from the JQuery Plugin page) that in addition to using the <g:javascript library="jquery"/>
tag, I had to add the plugin label explicitly to make the tag look like:
<g:javascript library="jquery" plugin="jquery"/>
Any idea why I had to use the plugin property?
Steve after installing Jquery plugin thru grails install-plugin jquery you have to execute another grails command to download the jquery file in your app
grails installJQuery
This target downloads and installs jquery-1.7.1.js and jquery-1.7.1.min.js under web-app/js/jquery/
I saw a good tutorial on that in icodeya. http://www.icodeya.com/2012/09/grails-different-ways-to-import.html
you can either do this in your gsp:
<g:javascript src="myscript.js"/ >
OR you can do this in your Config.groovy:
grails.resources.modules = {
core{
resource url:'/js/jQuery.js'
}
myScript {
resource url:'/js/myScript.js'
dependsOn 'core'
}
}
then, in your gsp, you can attach this:
<r:require module="myScript" />