facebook

click fire twice

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #343544 Reply

    Hi everyone

    I’m struggling with a small probmem!

    This code is placed in my #m1-page-custom.js. under in a function I call when i change Screen. Phone number, email, and url are all correct in the alert box – BUT the alert pops up twice when I click – why is that?

    (MobiOne 2.5 – 3)

    $(‘#m1-item-txtCall’).html(‘<img src=”images/icon_call.png” width=”50″>’).click(function(){
    alert(phone);
    });

    $(‘#m1-item-txtSms’).html(‘<img src=”images/icon_sms.png” width=”50″>’).click(function(){
    alert(phone);
    });

    $(‘#m1-item-txtEmail’).html(‘<img src=”images/icon_email.png” width=”50″>’).click(function(){
    alert(email);
    });

    $(‘#m1-item-txtUrl’).html(‘<img src=”images/icon_url.png” width=”50″>’).click(function(){
    alert(url);
    });

    #343583

    support-michael
    Keymaster

    >the alert pops up twice when I click – why is that?

    No idea atm. Can you provide as small example project and we can debug into it. I am assuming there is some interaction between a mobione widget and your html code but the snippet does not give me the full context to say any more.

    #343667

    Unknown Author
    Participant

    Double clicks have been a problem with Mobione buttons for a loooong time.

    #343689

    support-vadim
    Participant

    Hi TKT,

    Could you please provide minimal sample that reproduces the problem?
    I tried to create one ( http://goo.gl/Z8VKsr ) – but I always see only one alert.
    If for some reason you can’t provide sample – could you please add alert just before the subscribing to clicks, f.e.

    
    alert("Adding click handler");
    $('#m1-item-txtCall').html('<img src="images/icon_call.png" width="50">').click(function(){
    alert(phone);
    });
    

    to be sure you’re subscribing to click events only once?

    And the last thing – if you’re working with M1 push buttons (not custom HTML in CustomHTML control) – you’d better use “OnClick action”->”Run JavaScript” instead of manually subscribing to “click” action in JQuery.

    Regards,

    Vadim Ridosh

    #343710

    support-vadim
    Participant

    Hi TKT,

    We’ve received your files, thanks for providing them.

    But the problem you’re reporting is not related to M1. It’s actually the way you’re subscribing to click events. You do this on each page transition event, so when you visit page second time your click handler is called twice, when you visit it third time – three times, etc, etc. You can fix the problem through moving code that subscribed to clicks

    
      $("#m1-item-image_call").click(function(){
        var phone = "1111";
        alert("Call "+phone);
      });
    

    into phoneui.documentReadyHandler handler, or through applying this trick:

    
      $("#m1-item-image_call").unbind('click.anyid').bind('click.anyid', function(){
        var phone = "1111";
        alert("Call "+phone);
      });
    

    (I’ve found this trick here: http://stackoverflow.com/questions/8408826/bind-event-only-once/14208653#14208653 )

    Regards,

    Vadim Ridosh

    #343735

    RichardOne
    Member

    Hi,

    Been having this problem also,

    However, it only occurs with the ‘goback’ java code and not with page links?

    But here’s what’s strange (at least for me) when I have touched on all the java ‘Back’ buttons a few times the lag in transition disappears and no double click event?

    I’m wondering if this is a cache issue?

    Go figure…

    #343737

    support-vadim
    Participant

    Hi Richard,

    Could you please provide example and steps to reproduce the problem?

    Regards,

    Vadim Ridosh

    #343741

    Hmm – I’ve tried both now – and the problem still occurs. My problem is that i need the phonenumber, email and url are dynamically depending on which item clicked in the list. Is there any way that I can put the phonenumber in to a javascript on the m1?

    #343760

    RichardOne
    Member

    Hi Vadim,

    I simply uploaded the app to my phone; scrolled through the content.

    Each time I selected a ‘Back’ button using the ‘goback’ jave function, there was/is a distinct ‘double’ firing event and then the page ‘flickers’ momentarily prior to transition to target page.

    I have double checked everything; nothing seems obvious in terms of errors.

    #343763

    support-vadim
    Participant

    @TKT wrote:

    Hmm – I’ve tried both now – and the problem still occurs. My problem is that i need the phonenumber, email and url are dynamically depending on which item clicked in the list. Is there any way that I can put the phonenumber in to a javascript on the m1?

    Hi TKT,

    It seems I caught the scenario you’re talking about.
    You can workaround it through using M1 actions instead of jQuery handlers.
    I mean, in your viewItem function you should write something like this:

    
      $("#m1-item-image_call").data("phone", "1111");
      $("#m1-item-image_sms").data("sms", "1111");
      $("#m1-item-image_email").data("email", "support@DealsNearbyYou.com");
      $("#m1-item-image_url").data("http", "http://DealsNearbyYou.com"); 
    

    Then, in your item.mobi you should assign “Run Javascript” actions to your image buttons and write there something like this

    
    phoneui.alert($(this).data("phone"));
    

    This should fix the problem.

    Regards,

    Vadim Ridosh

    #343766

    support-vadim
    Participant

    Hi Vadim,

    I simply uploaded the app to my phone; scrolled through the content.

    Each time I selected a ‘Back’ button using the ‘goback’ jave function, there was/is a distinct ‘double’ firing event and then the page ‘flickers’ momentarily prior to transition to target page.

    Hi Richard,

    I’ve created simple Android app that contains tons of back actions, here is a link to it http://goo.gl/lUcImz
    I’ve tested it on several Android devices and all back actions work OK.
    Does it work OK on your device?

    For the case you want to change something to reproduce the problem there are sources of this app: https://drive.google.com/file/d/0B6LZd0Fjqwr2WXBqc012QzlDc2s/edit?usp=sharing

    Regards,
    Vadim Ridosh

    #343768

    RichardOne
    Member

    Octavio,

    Your test works perfectly?!

    So it must be something to do with the button code right?

    Are you using the came code?

    Thank you for taking the time to compose the test app 🙂

    #343811

    Thanks support-vadim,

    that did it 🙂

    #344030

    RichardOne
    Member

    Hi Vadim,

    It’s not the transitional effects; its the java ‘goback’ function

    This is not in your demo

    #344077

    Hi Richard,

    We have posted a special Android app that will record all key event and UI state data in order to help us to figure out how to replicate the issue, we will require your assistance with testing the app, find the download link in this thread:
    http://www.genuitec.com/support-genuitec/viewtopic.php?p=21758#p21758

Viewing 15 posts - 1 through 15 (of 22 total)
Reply To: click fire twice

You must be logged in to post in the forum log in