Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

.click() event does not work on latest jqm on touchscreen device (tested on iOS) #1857

Closed
pascalchristian opened this issue Jun 20, 2011 · 8 comments
Milestone

Comments

@pascalchristian
Copy link

Using JQM latest and JQuery 1.6.1, click() event binded to hyperlink does not work on touch screen devices. JQM alpha 4.1 works well.

@pascalchristian
Copy link
Author

I wrote a demo:

Using alpha 4:
[link-removed]

Using latest:
[link-removed]

@scottjehl
Copy link

I think if you need to catch a touch/click event before our ajax handling gets to it, you'll need to bind to the vclick event, which is what we use to normalize tap and click handling across devices. Will that work for you?

@ghost ghost assigned scottjehl Jun 20, 2011
@pascalchristian
Copy link
Author

$('#foo').live("pageshow", function() {
$('#link').vclick(function() {
alert('this is a test of .vclick()');
});
});

Set a whitescreen (the page does not load). The page does load with .click(). Using $(document).ready(function(){ does not work as well. This is a demo:
[link-removed]

@pascalchristian
Copy link
Author

Using .tap() makes it work with touchscreen devices, but does not work on chrome. If vclick is the normalized tap/click handling, then why does .click() works on alpha 4?

@scottjehl
Copy link

Actually, vclick isn't defined as a plugin, just an event (we can consider adding that).
For now, you can use all of the v events via bind:

$('#link').bind("vclick", function() {

Let me know if this helps!

@scottjehl
Copy link

I'm working on this now. Can you explain how you're using click for me?
Are you trying to prevent a link from changing pages on click? Or just adding some behavior to a link before the page changes when it's clicked?

Thanks!

@scottjehl
Copy link

Please grab latest and retest. If you need to bind logic to click, you may need to disable the new useFastClick option, depending on what you're trying to do. That said, I'm not sure the code example above is exactly how we'd recommend doing it. You might have better luck scoping a live click event to the page you're referring to, so that it isn't re-called every pageshow. Pagecreate can help there too.

Also, try delegating off the body to catch a click early, regardless of the setting above.

@pascalchristian
Copy link
Author

Thanks, .bind('vclick') seems to work. I am using pagecreate however on some pages I would need to attach a click event to generated content so therefore I would need to use pageshow. Regarding usage I need to add extra behaviour when its clicked (passing variables) and also prevent a link from changing pages (intercepting, e.g. for javascript commands such as manipulating google map -- I just added return false; to my code).

I am not really sure what do you mean by delegating off the body. Do you mean putting the script on head?

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

No branches or pull requests

2 participants