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 Contributor
Posts: 4
Registered: ‎02-09-2011
My Device: Torch
Accepted Solution

BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

Hi,

 

I'm developing a web application targeting OS6 devices (Torch and none-touch devices, e.g. Curve 9300). The problem is that an 'onclick' event does not fire when you use a Trackball to click on the object (Torch and Curve 9300).

 

It seems to be an OS6 (browser) bug as an 'onmouseover' works without a problem.

 

 

<button id="test-button" type="button">Click me!</button>
...
...

var submitButton = document.getElementById('submit-button');
submitButton.onclick = testOnClick;

function testOnClick() {
alert('onclick never gets triggered by trackball, but when you touch the button it does!');
}

 

 

This is causing an issue to roll the application out to a mixed environment of the OS6 devices.

 

Anybody else has a similiar problem, or I'm missing something?

 

Thanks

 

 

 

 

 

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

Re: BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

I'm not sure if it is just a typo in your example.. but your code where you select the element via getElementById() is using an id different than the id used on your button listed above it

 

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 4
Registered: ‎02-09-2011
My Device: Torch

Re: BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

It is just a typo in my example as I was taking code out my app for this posting.

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

Re: BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

I haven't heard/seen any problems with the click from the trackpad for onclick events with OS6.  Are you sure that the JavaScript code doesn't have an error in it somewhere making the onclick code not fire?

 

I believe as soon as the browser encounters a syntax or other error in the JavaScript it will stop processing the rest of the JS on the page

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 4
Registered: ‎02-09-2011
My Device: Torch

Re: BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

There are no errors on the page. I checked with Chrome and Safari debuggers. So, when you click on the button with any desktop browser, the alert pops.

 

In OS6 the 'onclick' event does not trigger at all, but 'onmouseover' it does trigger. If you touch the button in Touch device, the alert will display, but the mouse click does not trigger event.

 

 

 

<button id="test-button" type="button">Click me!</button>
...
...
var testButton = document.getElementById('test-button');
testButton.onclick = clickMe;        

function clickMe() {
     	alert('Click event triggered by touch, but does not get triggered by trackball!'); // tested with Torch and Curve 9300 (both OS6)
}   

 

If you copy the code above (no typos now ;-))), you should be able to reproduce the issue.

 

Thanks for a quick reply.

 

Sasha

 

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

Re: BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

Hi Sasha,

 

I've tried the below code on the following simulators:

Torch 9800: 6.0.0.227, 6.0.0.246, 6.0.0.337

Style 9670: 6.0.0.309

 

NOTE: I couldn't find a 9300 simulator with 6.0

 

This code all seems to run properly on these builds using the trackpad to move the pointer to the button and then click it...

 

Are you perhaps performing document.getElementById() in an inline script for the page that is not tied to a document loaded event?  I'm wondering if the document object isn't loaded yet before you grab a reference to it?

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
	<head>
	    <meta name="viewport" id="viewport" content="height=device-height,width=device-width,user-scalable=no" />
		<title>Untitled Page</title>
        <script type="text/javascript">

            function doLoad() {
                var testButton = document.getElementById('test-button');
                testButton.onclick = clickMe;
            }

            function clickMe() {
                alert('Click event triggered by touch, but does not get triggered by trackball!'); // tested with Torch and Curve 9300 (both OS6)
            } 
        
        </script>
	</head>
	<body onload="doLoad();">
        <button id="test-button" type="button">Click me!</button>
	</body>
</html>

 

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Contributor
Posts: 4
Registered: ‎02-09-2011
My Device: Torch

Re: BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

Tim, you're right. It's not an OS6 issue.

 

As I mentioned, I use a 'Sencha Touch' mobile framework for development and the code example came from the app I've been working on.

 

I did some digging and found out the following:

 

After the Sencha Touch is loaded and before the application is initilized, the Sencha Touch framework wraps around native browser's event object with its own EventObject in order to normalize cross-browser differences. So, the issue is with Sencha's 'onclick' implemenation... I'll follow with them.

 

Sorry for the false alarm... and once again, thanks for your quick response.

 

Regards,

Sasha

New Member
Posts: 2
Registered: ‎03-30-2011
My Device: Bold 9650
My Carrier: Verizon

Re: BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

I figured out a solution. It's a bit of a hack and requires modifying their original source code.

 

I wrote it up in a blog post so I can remember where I put it:

 

http://resilientcoder.blogspot.com/2011/03/getting-sencha-touch-to-work-on-non.html

 

 

Highlighted
New Member
Posts: 2
Registered: ‎03-30-2011
My Device: Bold 9650
My Carrier: Verizon

Re: BUG: OS6 / JavaScript 'onclick' Event Not Firing when Using Trackball

Here's a follow up on how I got scrolling to work.

 

http://resilientcoder.blogspot.com/2011/04/sencha-touch-scrolling-non-touch.html