I am creating a specialized calculator app with jquery mobile that has a lot of buttons.
My issue is when users tap buttons faster than they can be processed, sometimes taps get queued only to show up as a double tap the next time the button is tapped. A user hits buttons "1", "2", "3" and "4", "1234" should be displayed in another element. Instead you might see "134". And when you tap the "2" again, the display reads "13422". You can tap any number of other keys in the meantime, each getting processed, but the next time you hit "2" the tap event fires twice.
I capture all button taps, then process them based on a data-tag attribute.
$('button').tap(function (event) {
var tag = $(this).attr("data-tag")
switch (tag){
case "1":
\\ do stuff
break;
case "2":
//do stuff
break;
case "3":
//do stuff
break;
}
});
I tried disabling the button during processing and re-enabling them later like this,
$('button').tap(function (event) {
$(this).prop('disabled', true).button('refresh');
// process the taps
$(this).prop('disabled', false).button('refresh');
});
but this doesn't fix the problem.
How do I get all queued events to process without this strange trigger of a second tap?