> 2. Define the js function in GSP but be careful that you must put the
> scriptlet in the scope of <body> because of sitemesh which is the default
> layout engine of Grails.
This is not true. Most of my JS code lives within the <head> tag on
my pages. I don't have any problems with defining my code in the
<head> block.
It may not change anything, but it might look cleaner to use the
grails js tag:
change
<script language="JavaScript" src="${resource(dir: 'js', file:
'jquery-1.5.2.min.js')}"></script>*
to
<g:javascript src="jquery-1.5.2.min.js"/>
You can also use Firebug ( a Firefox plugin) to verify that the JS
source is getting loaded.
You showed me how you're defining your functions, but not how or where
you're calling them. If you're getting function not found problems,
than it's likely that the functions are being called before they're
loaded. You may want to try making your js calls from within a
$(document).ready(function() {
});
code block, if possible. This will insure that the page is loaded
(along with all js files) before actually executing any js calls.
So, I see the function definitions, but could you tell me how you're
calling them?
--MJ
On Apr 15, 2:33 am, Phoenix <
phoe...@linkpower.com> wrote:
> Hi, kouser
>
> Please refer the following sample:
> 1. Include the js file in folder "<your project root>/web-app/js"
> *<head>*
> * <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>*
> * <meta name="layout" content="main"/>*
> * <script language="JavaScript" src="${resource(dir: 'js', file:
> 'jquery-1.5.2.min.js')}"></script>*
> * <title>Hello, JQuery</title>*
> *</head>*
>
> 2. Define the js function in GSP but be careful that you must put the
> scriptlet in the scope of <body> because of sitemesh which is the default
> layout engine of Grails.
> *<body>*
> *........*
> *<script>*
> * function clearMsg(_id){*
> * $("#msg_" + _id).html(" ");*
> * }*
> *
> *
> * function update(_id)*
> * {*
> * }*
> *
> *
> *.......*
> *</body>*
>
> On Wed, Apr 13, 2011 at 8:59 PM, kouser neyaz <
kouser.ne...@gmail.com>wrote:
>
>
>
> > Hello All,
> > I am new to Grails and getting some issues,i am unable to include
> > javascript
> > in gsp page.I would appreciate if any one could share code to call
> > javascript function from textField and calendar datePicker.I need to
> > call a
> > javascript function onblur() or onfocus() or any other user defined
> > function.
> > please let me know if you need any more clarification.
> > Thanks in advance
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Grails User Group (GUG)" group.
> > To post to this group, send email to
gra...@googlegroups.com.
> > To unsubscribe from this group, send email to
> >
grails+un...@googlegroups.com.
> > For more options, visit this group at
> >
http://groups.google.com/group/grails?hl=en.
>
> --
> Best Regards
>
> **************************************************
> Phoenix
> Mobile : 68540371
> Email :
phoe...@linkpower.com