I have reduced the code to the following:
- If there's an onclick it's called
- And if there's no onclick the iPad won't see other click events
- But if there is on e all events are called
- And if we add one everything works
Update
Now it looks much simpler than when I originally asked this question 10 months ago; using modern Mobile Safari, All click handlers will be registered normally. So, go ahead, just use $(…).click(function(){})!
var hitEvent ='ontouchstart' in document.documentElement
?'touchstart '
:'click';
$('#dynamic').bind(hitEvent, function() {alert("works")});
$('#dynamic-with -onclick').bind(hitEvent, function() {alert("works")});
$('#dynamic-with-dynamic-onclick').bind(hitEvent, function() {alert( "works")}).attr('onclick','');
Another way is to bind to multiple events and be satisfied with anyone who is called.
I am currently using the first solution; I might try the other one because I think it is cleaner.
I have one that uses jQuery and a lot of dynamics The item that generates the content. There is a click handler on the upper left element-“active” score-it works fine on desktop Safari but is not called at all on Mobile Safari; the gray overlay will never appear, and no action will be taken . The same situation as the click handler and state on the click area (172 on the right) (“add state effect” at the bottom; confirmation; it appears on the portrait): all work is on the desktop but not mobile Safari.
I have reduced the code to the following:
$(function() {
$('#dynamic').click(function() {alert("works")});
$('#dynamic-with -onclick').click(function() {alert("works")});
$('#dynamic-with-dynamic-onclick').click(function() {alert("works") }).attr('onclick','');
})
< br />
- If there's an onclick it's called
- And if there's no onclick the iPad won't see other click events
- But if there is one all events are called
- And if we add one everything works
Update
It now looks much simpler than when I originally asked this question 10 months ago; with modern Mobile Safari, all click handlers will be registered normally. So, going forward, just use $(…).click(function(){})!
We can do hackish things, just add onclick to whatever we want to click. But the “right” way to do this seems to be using suitable iPad activity:
var hitEvent ='ontouchstart' in document.documentElement
?'touchstart'
:'click';
$('#dynamic').bind(hitEvent, function() {alert("works")});
$('#dynamic-with-onclick').bind(hitEvent, function() {alert("works")});
$('#dynamic-with-dynamic-onclick').bind(hitEvent, function() {alert("works")}).attr('onclick' ,'');
Another way is to bind to multiple events and be satisfied with anyone who is called.
I am currently using the first solution ; I might try another one because I think it is cleaner.