I have a script to check/uncheck all boxes on a form in a grails application that I am trying to call. I included the function (in <g:javascript>
tags) in the head section of the page, and even added an alert before declaring the function to make sure the code block was being processed (it worked), but when I hit my check/uncheck all button, firebug tells me that it can't find the symbol; and looking at the source code, the function doesn't seem to be present. Where do I put this to get grails to include this function?
views:
45answers:
1
+2
A:
in your web-app/js library, naming it yourScript.js
You include them in your your page by
<g:javascript library="yourScript"/>
Notice the lack of .js in the tag
sbglasius
2010-05-26 18:14:52
You'd recommend this rather than just trying to put the script into the page inline? It was my understanding you could do either...
pennstatephil
2010-05-26 20:26:52
Ah, sorry. Missed the point... If you use Prototype, make this function: Event.observe(document,'dom:loaded',function() { //do init stuffhere }); Because if you put onclick events before the html, it will not register as the DOM is not yet established.
sbglasius
2010-06-04 07:29:34