benmajor / jQuery-Touch-Events

A collection of mobile event plugins for jQuery.
MIT License
699 stars 225 forks source link

.trigger('tap') don't work on mobile devices #132

Closed antoniogarcez closed 7 years ago

antoniogarcez commented 7 years ago

Hi,

I am trying to simulate a tap event in a input of type file but isn´t working.

This is my code: $(ButtonAddAttachmentElem).on('tap', function (event) { $(InputAddAttachmentElem).trigger('tap'); });

I've tested in Google Chrome in a Android 4.4 device.

ArsNV commented 7 years ago

Same problem on Android 7.1.2

benmajor commented 7 years ago

Plus could you put together a jsFiddle or similar which shows this behaviour?

antoniogarcez commented 7 years ago

This is a jsFiddle that represents my problem...

https://jsfiddle.net/uskgmdtg/3/

I've tested in my computer and also didn't work.

benmajor commented 7 years ago

Thank you, @antoniogarcez. The issue is that the special events provided by this library do not work with the browser in terms of triggering them for inputs and other items (they're essentially a composite of various events).

To fix your issue, you can simply trigger click on your hidden input: https://jsfiddle.net/uskgmdtg/4/

antoniogarcez commented 7 years ago

@benmajor, thank you for information.

When I saw that .trigger('tap') didn´t work, I was starting using .trigger('click') and worked. I thought that .trigger('tap') should work.

benmajor commented 7 years ago

Unfortunately not, it's one of the perils of this polyfill method. Hopefully using click suffices.

antoniogarcez commented 7 years ago

An advice, please correct the documentation because will mislead developers. You have this in your documentation:

Triggering the event:

$('#myElement').trigger('tap');

antoniogarcez commented 6 years ago

Hi @benmajor ,

Did you do any correction? Today, I've tested and it works. 👍

benmajor commented 6 years ago

Hi Antonio, nothing was changed in the library. Did you upgrade jQuery?

antoniogarcez commented 6 years ago

I can not remenber but it's possible. Do you know if they change anything?