views:

45

answers:

1

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?

+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
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
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