Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8338555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:37:30+00:00 2026-06-09T04:37:30+00:00

I have a application built on groovy and Grails (grails version 2.0.4). I;m using

  • 0

I have a application built on groovy and Grails (grails version 2.0.4). I;m using the grails jQuery -plugin

in a gsp page if i try something like this

 <script type="text/javascript">

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

</script>

gives me in error in console

      Uncaught ReferenceError: $ is not defined list:24
      (anonymous function)

but if i try something like this

    <r:script>

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

    </r:script>

it alerts as expected.

grails jQuery plugin installs jquery version 1.7.1

what is causes this behavior/error?

when i see the page source i see that jQuery is loaded after the script tag

how to fix it?

My main.gsp page

    <!doctype html>
   <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
   <!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
   <!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
   <!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
   <!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"><!--<![endif]-->
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <r:require modules="jquery"/>
    <title><g:layoutTitle default="Grails"/></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="${resource(dir: 'images', file: 'favicon.ico')}" type="image/x-icon">
    <link rel="apple-touch-icon" href="${resource(dir: 'images', file: 'apple-touch-icon.png')}">
    <link rel="apple-touch-icon" sizes="114x114" href="${resource(dir: 'images', file: 'apple-touch-icon-retina.png')}">
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'main.css')}" type="text/css">
    <link rel="stylesheet" href="${resource(dir: 'css', file: 'mobile.css')}" type="text/css">
    <g:layoutHead/>
     <g:javascript library="jquery"/>
    <r:require module="application"/>
    <r:layoutResources />

</head>
<body>
    <div id="spinner" class="spinner" style="display:none;"><g:message code="spinner.alt" default="Loading&hellip;"/></div>
     <div class="page_header">
        <g:render template="/templates/header" />
    </div>
    <div class="container">
        <div class="left_column">
            <g:render template="/templates/commonMenu" />
        </div>
        <div class="center">
            <g:layoutBody />
        </div>
    </div>
    <div class="footer">
        <g:render template="/templates/footer" />
    </div>

</body>
 </html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:37:31+00:00Added an answer on June 9, 2026 at 4:37 am

    Check documentation of the Grails Resourses plugin first to understand how it works and how to use it.
    When you use script tag it will be rendered where it was defined. But if you use r:script then it will be rendered after all modules (including jQuery) at the end of the page (usually).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application built using JSF1.2. I have a home page which has
I have code scattered through a Service in a plugin, using AntBuilder like this:
I have a Cocoa application built using Garbage Collection with a main window. This
I have an application built for iPhone 2.0 but I would like to use
I have an application which is built from command line (ANT) using J2ME Polish.
All, I have a PHP Web application built using Zend Framework and MVC with
I have an application built using PhoneGap (Android) that is essentially a shell for
I have an application built with GWT/Appengine/Jdo...and i am using Google User Service for
Alright so this is an odd one... I have an application built in ColdFusion
I have an application built in Delphi and it accesses MySQL database using MyDAC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.