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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Web and WebWorks Development

Reply
Trusted Contributor
shea08
Posts: 116
Registered: ‎03-25-2009
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.... 

Please use plain text.
Developer
rorybarnes
Posts: 214
Registered: ‎01-07-2011
My Carrier: Rogers

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
Please use plain text.
Contributor
reng2012
Posts: 36
Registered: ‎02-04-2012
My Carrier: Break Wind

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.
Please use plain text.
Developer
rorybarnes
Posts: 214
Registered: ‎01-07-2011
My Carrier: Rogers

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
Please use plain text.
Developer
shnuffy
Posts: 268
Registered: ‎08-19-2009

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.

Please use plain text.
New Member
zeissChoice
Posts: 1
Registered: ‎04-20-2012
My Carrier: 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),
Please use plain text.