No JQuery clicking the handler on the iPad

I have a project that uses jQuery and a lot of dynamically generated content. There is a click handler on the upper left element-“active” score-it works fine on desktop Safari but on Mobile Safari There is no call at all; the gray overlay will never appear, and no action will be taken. With the click handler and status on the click area (172 on the right) (“Add Status Effect” at the bottom; confirm; it appears in the portrait Above) is the same: all work is on the desktop but not mobile Safari.

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(){})!

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 an activity suitable for iPad:

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.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1012 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.