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
Contributor
Posts: 32
Registered: ‎05-05-2011
My Device: BB9700
My Carrier: mts
Accepted Solution

HTML5 Adding Listeners

Hi,

     I'm trying to add an listener to check the coverage information. I'm using PhoneGap and BB6. So when I add the below line, Nothing happens.

 

document.addEventListener("online", onOnline, false); 
document.addEventListener("offline", onOffline, false); 

 

Dont know if this is the right place to post this question. Also Other than PhoneGap, is there any other way to add event Listeners from BB WW application?

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: HTML5 Adding Listeners

Hmm... I'm not sure if BB6 has the HTML5 online/offline events.

 

You can use the hasDataCoverage() method and onCoverageChange event as an alternative

 

http://www.blackberry.com/developers/docs/webworks/api/blackberry.system.html

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 32
Registered: ‎05-05-2011
My Device: BB9700
My Carrier: mts

Re: HTML5 Adding Listeners

WOW!! onCoverageChange Should work. Thanks for the reply Tim. Smiley Happy
Developer
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: HTML5 Adding Listeners

Hi

 

Online and Offline events work fine for me.

e.g.

            window.addEventListener("online", online_function, false);

            window.addEventListener("offline", offline_function, false);

 

 

Cheers

Andrew

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: HTML5 Adding Listeners

Hi Andrew,

 

Does this work for you on BB6?

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 32
Registered: ‎05-05-2011
My Device: BB9700
My Carrier: mts

Re: HTML5 Adding Listeners

Andrew,
How did you test it?
I tried changing Simulate->Network Properties->Unchecked "In Coverage".
I Also turned off all the connections in "Manage Connections->Turn All connections Off"
Contributor
Posts: 32
Registered: ‎05-05-2011
My Device: BB9700
My Carrier: mts

Re: HTML5 Adding Listeners

Hey Tim/Andrew,

Finally I got it working for me. I made two mistakes here.

  1. I used PhoneGap version 9.5, but this is available from 9.6.
  2. I didn’t execute “document.addEventListener("deviceready", onDeviceReady, false);” in the HTML file. Rather this was called in another file.

Now I got it working. Thanks for all your time Woman Happy

Developer
Posts: 189
Registered: ‎08-13-2008
My Device: Not Specified

Re: HTML5 Adding Listeners

Hi Tim

 

Yes this works on BB6 and playbook.

 

This has been fully tested and is in production.

 

The app is NOT webworks though, its a pure browser html javascript app.

 

Cheers

 

Andrew