|
Hi there,
I'm facing a problem with sitemesh layouts and javascript calls. I'm applying a layout name="main" (grails standard) to my create page. Additionally, I want to include some javascript on this gsp, which is only used here. So there is no need to put it in the main layout. Unfortunately, my constraction isn't working. If I remove the <meta name="layout" content="main"/> column it works fine. What can I do to get this working with a layout? Any suggestions are appreciated... My create.gsp: The head section looks like this: <meta name="layout" content="main"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>Create</title> <script src="http://maps.google.com/maps?file=api&v=2&key=abcdefg" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ </script> <body onload="load()" onunload="GUnload()"> ... </body> Greets AGU |
|
Hi.
1. Remove onload="load()" onunload="GUnload()" from <body> 2. Put:
<script type="text/javascript"> document.body.onload=load(); document.body.onunload=GUnload();
</script> after the <body> It works for me :)
-- Kind regards,
Łukasz Matuszewski |
|
Hi
it's unfortunately not working for me. The result is still the same. I put this right after the body tag but I had no luck. Any other suggestions? Greets AGU
|
|
Can you send generated html source?
|
|
Sure.
This is generated HTML with your solution. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Create Entry</title> <link rel="stylesheet" href="/appname/css/main.css" /> <link rel="shortcut icon" href="/appname/images/favicon.ico" type="image/x-icon" /> <meta name="layout" content="main"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <script src="http://maps.google.com/maps?file=api&v=2&key=abcdef" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(51.297607421875, 9.482611656188965), 6); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); } } //]]> </script> <script type="text/javascript" src="/appname/js/application.js"></script> </head> <body> <div id="spinner" class="spinner" style="display:none;"> ![]() </div> <div class="logo"> </div>
<script type="text/javascript"> document.body.onload = load(); document.body.onunload = GUnload(); </script><div class="nav"> Home Entry List </div> <div class="body"> <div class="create"> Create Entry<form action="/appname/entry/save" method="post" > <div class="dialog"> <div class="buttons"> <input class="save" type="submit" value="Create"/> </div> </form> </div> <div class="preview"> Preview Entry<div id="map" style="width: 600px; height: 530px"></div></div> </div> </body> </html>
|
|
Try to put some alerts to load() function to check if this method is called on page load and if document.getElementById("map") is not null.
|
|
I figured out that map is actually null. How do I get this "map" element via javascript? I tried to figure out the xpath to this element but it didn't help.
|
|
Check if you have div with id="map" and put this code:
document.body.onload = load(); document.body.onunload = GUnload(); before the load() method. |
|
Mmh, I think there is a problem in the order of calling the functions. And yes, when I look at the generated html code, I always have the div with id=map. It seems that the load() function is not being called when I'm using document.body.load(); My assert isn't showing.
|
|
In reply to this post by A_Grails_User
I can't figure it out. Always, when I "switch on" the line <meta name="layout" content="main" />, my javascript function load() is never being loaded again. Why is that? Do I have have to pay attention to a specific order while decoration the page?
Greets AGU
|
| Powered by Nabble | Edit this page |
