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

5 posts, 1 answers
  1. Idan
    Idan avatar
    76 posts
    Member since:
    Oct 2012

    Posted 24 Oct 2013 Link to this post

    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.
  2. Answer
    Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 24 Oct 2013 Link to this post

    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!
  3. Idan
    Idan avatar
    76 posts
    Member since:
    Oct 2012

    Posted 24 Oct 2013 Link to this post

    Thanks for the quick answer, I will check it out. Can I pass parameters to the called function using this method?
  4. Jan-Dirk
    Jan-Dirk avatar
    327 posts
    Member since:
    Jun 2012

    Posted 24 Oct 2013 Link to this post

    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);
    }
  5. Idan
    Idan avatar
    76 posts
    Member since:
    Oct 2012

    Posted 24 Oct 2013 Link to this post

    The data-click works like a charm :)

    Thanks!
Back to Top