This is a migrated thread and some comments may be shown as answers.

Click event on Android doesn't work (sometimes do)

4 Answers 145 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Idan
Top achievements
Rank 1
Idan asked on 24 Oct 2013, 11:18 AM
I am having problem with catching  click events / tap events on my Android device. I've tested it for over a few hours.

$("#button").click(function(e) {
            alert("as");
        });

In the simulator I get the alert, whether on my mobile device I don't get the alert. Sometimes it works, but as for now, it doesn't. I've spent hours on that simple thing and can't solve the problem. I rebuilt the project but still the problem exists.

Any suggestions?

Update: it seems like a bug. When I build it, it sometimes work, sometimes don't without me touching the code.

4 Answers, 1 is accepted

Sort by
0
Accepted
Jan-Dirk
Top achievements
Rank 1
answered on 24 Oct 2013, 11:43 AM
Are you using Kendo? If so, you can define the click event in html like this:

<a id="mobile-button" data-click="logClick" data-role="button">Trigger Event</a>

Clicking on the button results in "logClick" being fired.

I hope this helps!
0
Idan
Top achievements
Rank 1
answered on 24 Oct 2013, 11:46 AM
Thanks for the quick answer, I will check it out. Can I pass parameters to the called function using this method?
0
Jan-Dirk
Top achievements
Rank 1
answered on 24 Oct 2013, 11:51 AM
Not sure, but you can't pass parameters the way you are currently handling the click either :)

I think the function logClick could look like this to handle system parameters:
function logClick(e) {
   // handle the e parameter
   console.log(e);
}
0
Idan
Top achievements
Rank 1
answered on 24 Oct 2013, 12:13 PM
The data-click works like a charm :)

Thanks!
Tags
General Discussion
Asked by
Idan
Top achievements
Rank 1
Answers by
Jan-Dirk
Top achievements
Rank 1
Idan
Top achievements
Rank 1
Share this question
or