<a> tag onclick event not firing reliably when tapped on iPod Touch Safari

Ast35
Ast35 used Ask the Experts™
on
We are building a mobile website using JQTouch, and we need to trigger a Javascript function when a link is tapped, but the onclick event seems to be firing only some of the time. I think it has to do with the amount of pressure used for the tap. The link itself is being followed all the time, but the function only executes some of the time. Which isn't much good as the div the link goes to is supposed to display information output by the function.

Any ideas?

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Can I see how you have your link set up?

Author

Commented:
<a id="getresultsbutton" class="flipleft getresults" href="#results"  onclick="getInitialresults(); " >Get results</a>

It works as expected when I click it in Firefox.
You might want to consider disabling the href with something like "javascript:void(0);" and placing a window.location = "http://yoursite.com/"; in your getInitialresults() function.
leakim971Multitechnician
Top Expert 2014

Commented:
Try to use a DIV instead a link
Commented:
I tried those, and the result was that getInitialresults() was executing, but the site was not transferring to the correct screen (despite the correct URL displaying in the address bar).

But I've got it working.

I found a 'tap' event specific to the JQTouch plugin. I removed onclick="getInitialresults(); " and added the following -

                $('#getestimatesbutton').bind('tap', function () {
                    getInitialEstimates();
                })

It is odd that the onclick event was only working some of the time though.

Thanks for trying to help!

Author

Commented:
Accepting my own post as the solution so that I can close the question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial