Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery trigger click mobile Safari (iPad)

I have stumbled upon a bug in Safari on iPad.

$('#next_proj a').trigger('click');

.. does not seems to click on the actual link.

Any clues?

like image 626
emilolsson Avatar asked Aug 22 '10 22:08

emilolsson


1 Answers

I got this to work by doing this...

var el = $('#next_proj a').get(0);
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(evt);

Hope it helps...

like image 162
ad rees Avatar answered Sep 29 '22 10:09

ad rees