Reputation: 1587
I'm using third-party javascript library and I want to emulate clicking on some element. $('#element').trigger('click');
And it works, but when I try this at my Android device, it doesn't work. I don't know how that third-party library works, but when I tap on the element, it fires, how can i detect which event is fired and call it from the javascript? Thanks!
Upvotes: 0
Views: 1528
Reputation: 36005
It is most likely that the plugin is using touchstart
event when on mobile. However, this may not be the same for all mobile devices, so it would not be best to rely on that fact.
There is no easy way to detect — from a JavaScript point of view — what event has been applied to which element (in native terms), at least as far as I know. Different versions of jQuery do store the events that have been applied using that instance of jQuery, which you can access via the .data()
method. However this is not standardised and jQuery keep changing the way they are stored, so it is unreliable.
Your best bet is to find some kind of plugin that works for your browser, I have a number of plugins tied into Firebug (for Firefox) which help with a number of jQuery queries... however, getting these to feed back from mobile would be tricky and I have not tried anything like this myself.
Upvotes: 1