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
New Member
Posts: 1
Registered: ‎02-23-2010
My Device: Bold 9000
My Carrier: AT&T

Widget SDK - setTimeout help needed

I'm trying to use setTimeout to control the execution length of an Ajax call, however, the call fails every time I try to call window.setTimeout or setTimeout.

I am using the Prototype JS framework with the following syntax:

(window.)setTimeout(this.handleTimeout.bind(this), this.options.timeout);

 

I am using Widget SDK beta 3 with Blackberry 9000 simulator.

Any ideas?

 

 

Thanks,

Udi

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

Re: Widget SDK - setTimeout help needed

Hi Udi,

 

I have never had a problem with the setTimeout in the BlackBerry browser.  My guess is that there is a JavaScript error in your "this.handleTimeout.bind()" function.

 

If you do the following simple example it should work:

 

function handleTimeout() {
   alert("hello world");
}

setTimeout(handleTimeout(), 3000);

 

If a JavaScript error happens in the BlackBerry Browser, it doesn't display that error to the end user.  It suppresses it.  What I would do is put a try catch around the code in your bind() method and put an alert in the catch to see what the error message is.

 

 

I would also double check that your "this.handleTimeout" and "this.options.timeout" are defined and valid before calling the setTimeout().  It may be throwing an "undefined" error at that point as well.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter