0

I've got this in my GSP in <head> section:

<g:javascript library="jquery"/>

but no effect in the resulting HTML - this is the problem to be solved.

jQuery plugin was installed by initial grails installation:

C:\...\qotd>grails install-plugin jquery
| Plugin 'jquery' with version '1.7.2' is already installed

And this code in GSP

<g:remoteLink action="ajaxRandom" update="quote">Next Quote</g:remoteLink>

results in html (calling jQuery.ajax method):

<a href="/qotd/quote/ajaxRandom" onclick="jQuery.ajax({type:'POST', url:'/qotd/quote/ajaxRandom',success:function(data,textStatus){jQuery('#quote').html(data);},error:function(XMLHttpRequest,textStatus,errorThrown){}});return false;" action="ajaxRandom">Next Quote</a>

But of course no ajax methods are called and this link leads directly to another URL, because no jQuery is included in the head section. This is the problem.

Where did I go wrong? Thank you!

Michael Zelensky
  • 1,781
  • 3
  • 22
  • 34

1 Answers1

1

You need to add <r:layoutResources/> after your javascript library include.

Todd Murray
  • 423
  • 2
  • 7