Attached Binding Link Inactive on Safari / iPhone

I have a function used by many different parts of my site that brings up a confirmation window. When it is called, it formats a box with various elements and attaches it to the body, for example ...

$('body').append("<div id=\"confirmation\"><a href=\"javascript:confirmed()\">confirmed</a> <a href=\"javascript:closeConfirm()\">cancel</a></div>"); 

Now this works great because everyone accepts the Safari iPhone browser, which doesn't seem to be activated, or loads the anchor into the DOM correctly ... it's not clickable . This is the problem: the window is displayed correctly, touching the anchor does nothing. Console.log proves this.

Any ideas?

+4
source share
3 answers

This particular situation was resolved by moving the anchor so as not to overlay the embedded video. When the anchor was placed on top of the embedded video on the iPhone - touch events above, they were ignored in favor of the touch that you need to perform to quickly play and play the video.

0
source

Have you tried to do

 $div = $('<div>', { id : "confirmation"}); $aConfirmed = $('<a>', { href : "#", class : "confirmed", text: "confirmed"}); $aCancel = $('<a>', { href : "#", class : "cancel", text: "Cancel"}); $div.append($aConfirmed).append($aCancel); $('body').append($div); 

And then use some event handlers like (this assumes jQuery> 1.7

 $(document).on("click", "a.confirmed", function(){ confirmed(); }); $(document).on("click", "a.cancel", function(){ closeConfirm(); }); 
+4
source

Try using something other than a binding tag for testing and see if this works.

0
source

Source: https://habr.com/ru/post/1400422/


All Articles