0

I am trying to use jquery in a grails 2.1.1 app with jquery plugin v1.8.0.

My .js file is in 'web-app/js/'

My view heading is

<head>
<g:javascript library="jquery" plugin="jquery"/>
<g:javascript src="dataFeed.js"/>

This works:

alert("hello");

This doesn't:

$(document).ready(function(){
    alert("help");
});

Any ideas?

dagilmore
  • 35
  • 1
  • 6
  • Anything in the console? What about `$(function() { alert("ohai"); })`? – Dave Newton Jan 14 '13 at 23:21
  • $(function() { alert("ohai"); }) didn't work. `[17:34:19.430] GET http://localhost:8080/turingpages/factorize [HTTP/1.1 200 OK 106ms] [17:34:19.567] GET http://localhost:8080/turingpages/js/dataFeed.js [HTTP/1.1 302 Found 3ms] [17:34:19.585] GET http://localhost:8080/turingpages/static/js/dataFeed.js [HTTP/1.1 200 OK 2ms]` – dagilmore Jan 14 '13 at 23:35
  • 2
    Instead of ``, try `` – James Kleeh Jan 15 '13 at 02:27
  • 1
    There is an answer in http://stackoverflow.com/questions/8956799/how-to-include-jquery-js-in-grails – coderLMN Jan 15 '13 at 02:37

1 Answers1

0

Here's my jquery and jquery-ui setup in grails 2.4.x

Get the css and js files from jqueryui website and put them in grails-app/assets

<asset:stylesheet src="application.css"/>  
<asset:javascript src="application.js"/>    

<!-- jquery-ui assets -->
<asset:javascript src="jquery-1.9.0.min.js"/>   
<asset:javascript src="bootstrap.min.js"/>   
<asset:javascript src="jquery-ui-1.10.0.custom.min.js"/>   
<asset:javascript src="google-code-prettify/prettify.js"/>   
<asset:javascript src="docs.js"/>   
<asset:javascript src="demo.js"/>   
<asset:stylesheet src="bootstrap.min.css"/> 
<asset:stylesheet src="docs.css"/> 
<asset:stylesheet src="jquery-ui-1.10.0.custom.css"/> 
<asset:stylesheet src="font-awesome.min.css"/> 
<asset:stylesheet src="style.min.css"/> 

<!-- datatable assets -->
<asset:javascript src="jquery.js"/> 
<asset:javascript src="jquery-ui.js"/> 
<asset:javascript src="jquery.dataTables.js"/>  
<asset:stylesheet src="jquery.dataTables.css"/>  
biomq
  • 1
  • 2