Jquery Event Delegation fails on iOS

Source: Internet
Author: User

Click through the JS traversal out of the list, jump page. Click the event delegate on the document ,

Like this: $ (document). On ("click", ". Nav", function () {})

On the Web and Android on the degree of no problem, can jump normally. But clicking on iOS doesn't have any response. The reason: event delegates oniOS cannot be bound to document and iOS, and should be bound on other parent elements of it

$.each (Dataall,function(i,item) {str+ = ' <div class= ' nav shadow-black ' data-str= ' +Item.data_str+ ' "><div class=" Nav-item ">Item.myheadimgurl+ ' "/><div class=" ellipsis ">" +Item.myusername+ ' </div></div><div class= ' nav-item alike ' ><div>VS</div><div> ' +Item.addtime+ ' </div></div><div class= "Nav-item" >Item.compareheadimgurl+ ' "/><div class=" ellipsis ">" +Item.compareusername+ ' </div></div></div> ';                }); $("#shareContent"). html (str);
//iOS Click No response, no event triggered$(Document). On (' click ', '. Nav '),function(){    varDATA_STR = $ ( This). Data (' str '); Window.location.href= ' http://test.epoque.cn/user/footcompare/compare_foot?data_str= ' +data_str;})//delegate events to other elements, iOS click to jump$ ('#shareContent'). On (' click ', '. Nav '),function(){    varDATA_STR = $ ( This). Data (' str '); Window.location.href= ' http://test.epoque.cn/user/footcompare/compare_foot?data_str= ' +data_str;})

Another problem: Often in iOS a button can not point, like this <span> button </span>, the reason is the semantic problem, may use a tag or button, the solution: Add Style: Cursor:pointer.

Jquery Event Delegation fails on iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.