Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{{action}} handler does not work on touch devices #586

Closed
redeemedfadi opened this issue Mar 13, 2012 · 5 comments
Closed

{{action}} handler does not work on touch devices #586

redeemedfadi opened this issue Mar 13, 2012 · 5 comments

Comments

@redeemedfadi
Copy link

Adding an {{action}} helper to a tag and clicking that tag on a touch enabled device (tested on iOS) will not fire the attached event.

See: http://jsfiddle.net/Jwm46/4/

I understand that by default the {{action}} uses on="click". However, the "click" action should probably fire/receive the touchEnd event on touch devices.

@redeemedfadi
Copy link
Author

Discovered I can overwrite the touchend event by browsing the source. Not really a perfect solution but this fixed my problem: http://jsfiddle.net/Jwm46/5/

@manoharank
Copy link

@wagenet I also have the same problem, what would be the best solution for this?

@mattkime
Copy link

i'm using ember with jQuery Mobile and don't suffer from this issue. I'm not sure why but it might be worth digging through the jQM source.

@krisselden
Copy link
Contributor

This is an iOS problem with the event delegation pattern. Here is a working fiddle with 2 simple solutions.

http://jsfiddle.net/krisselden/Jwm46/6/

@krisselden
Copy link
Contributor

A little more explanation, click is only synthesized if the element is or is contained by an element with default click behavior (anchor with a href or a button), has a click handler (not including the body), or is styled with cursor: pointer.

Also the body tag is the only element that can delegate click events without being 'clickable' itself (so you are going to have a bad time if you make the rootElement of your Ember.Application an element other than the body).

Also, there is an subtle issue with using touchend to trigger actions, since the iOS browser will synthesize a click event 300ms later and deliver it to element in the same area, even if it isn't the original element that had touchend, if it is a plain a tag with href it will cause it to navigate.

So say you had a list of links that acted on touchend to render a detail view, and in the detail view was a link to google maps rendered in about the same place as the link in the list view, you would cause the link to be followed when you selected the list item.

Google calls this a 'ghost click' in this paper https://developers.google.com/mobile/articles/fast_buttons

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants