Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
Posts: 121
Registered: ‎03-25-2009
My Device: Z30
Accepted Solution

page load event happening twice

Consider the folowing code:

<html>
	<head>
	<script type="text/javascript">
		function log(line) {
			if( console == null || console.log == null )
			{
				return;
			}
			console.log(line);
		}

		function doSomething(context) {
			log("page load event, context is: " + context);
		}

		window.addEventListener("load", doSomething, false);
	</script>
	</head>
	<body>
		<h2> this is a test</h2>
	</body>
</html>

the "page load event, context is [object Event]" will be printed twice.  This is causing some havoc in my application. This only happens in the ripple emulator, not in any other browswer.


Is there a work around for this? I found that if I wrap it in a setTimeout I am ok, but that seems a little hokey.... 

Developer
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900

Re: page load event happening twice

It is a quirk with Ripple and how it loads pages. You may want to use your setTimeout function during your dev and pull it out when you test on device or submit.

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful
Contributor
Posts: 36
Registered: ‎02-04-2012
My Device: None

Re: page load event happening twice

You're joking!! How could they have released Ripple with a bug like that?! I am very disappointed with RIM's engineers.
Developer
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900

Re: page load event happening twice

As another solution rather than a setTimeout you could check for blackberry existing in your init (if you have one). 

if (typeof window.blackberry === "undefined"){
return false;
}

This should stop it running that first time before Ripple renders it.

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful
Developer
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: page load event happening twice

Honestly I don't use Ripple for anything but building, packaging and signing. Other than that, it's simulator or device testing for me.

New Member
Posts: 1
Registered: ‎04-20-2012
My Device: test

Re: page load event happening twice

i just document or delete below code in ripple.js that it is working fine.
//document.getElementById("viewport-container").removeChild(d),