A href (data-role=button) click fires twice

5 posts, 0 answers
  1. Cestrian
    Cestrian avatar
    17 posts
    Member since:
    Sep 2012

    Posted 13 Mar 2015 Link to this post

    Hi all!.

    I have really strange problem. I use jQuery (1.11.2) and most recent Kendo Mobile UI.

    My app is built from two .html pages. Simplified code below:

    Page 01 has code:
    <div data-role='content'>
       <a href="Fitter/Register.html" data-role="button">Register here!</a>
    </div>

    Page 02 has code:
    <div data-role='content'>
       <p id='javascriptOnClickRemoveContentOfThisDiv'>Java<p>
    </div>

    as you can see, both Register button and Paragraph are at the same position on screen although on different views. Now the strange thing that happens here is that user will click on Register here! button, Kendo will switch the view to Page02 and Java text from Paragraph is being removed by javascript function (below), so it looks like Register here! fires twice firstly on Page01 (as supposed) and then on Page 02 (why? - delayed event?, also it's not happening on all Android devices - just on some):
    $('javascriptOnClickRemoveContentOfThisDiv').click(function() {
         this.html('');
    });

  2. Cestrian
    Cestrian avatar
    17 posts
    Member since:
    Sep 2012

    Posted 13 Mar 2015 in reply to Cestrian Link to this post

    Small update. If I click on 'Register here!' extremely fast sometimes it's ok (On Page 02 jQuery code is not removing Java text automatically). Tried to use data-delay=10000 but it's not working with anchor ....
  3. Kendo UI is VS 2017 Ready
  4. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 17 Mar 2015 Link to this post

    Hi Phill,

    using the DOM click event is not reliable on touch devices. You should use the touch widget instead



    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  5. Cestrian
    Cestrian avatar
    17 posts
    Member since:
    Sep 2012

    Posted 17 Mar 2015 Link to this post

    Many thanks Petyo,
    Turning on transition effect sorted that out.

    So to be sure. If i remove href from anchor element and i add data-tap="myTouch.renderAnotherView" it should work as expected? How to render a View from javascript function? as so far <a href> and Kendo made that for me automatically.
  6. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 18 Mar 2015 Link to this post

    Hi Phill,

    you can use the kendo mobile application instance .navigate(url) method for that purpose. The transition also fixes it, since it "swallows" the DOM click event. 

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready