About the iphone Click event is invalid, Android no problem

Source: Internet
Author: User

Tag: Otherwise poi takes effect request point Add Ajax event Delegate click

Because to several lines of the page to do JS dynamic code, the diagram of the use of the jquery framework, it is also strange that they did not have detailed testing, the results of the page to others after the discovery of the jquery this bug, but also, at least some gains, if not this problem, I guess I didn't expect to see the official jquery bug list. This is something!

Why does the live binding of jquery expire on mobile safari? In fact, it can be traced back to the way live is implemented in jquery. The implementation of live is actually implemented through the event delegation mechanism, which means that the event is bound to the corresponding root node of the DOM tree in such a bubbling way that all nodes under this node will bind this event by default. Live on mobile Safari will fail because mobile safari may have prevented the event from bubbling (and here it is only speculation that the real reason is still being looked for), without binding the corresponding event to the root node, causing the problem.

jquery's use of live for event binding on mobile Safari will invalidate the following two solutions:

(1) Change the live binding to bind bind

However, this premise does not require event binding for dynamically generated elements, such as new elements created after an AJAX request.

Otherwise, the second solution is recommended.

(2) Add onclick= "" on the element that needs to be bound to the event (including the new element)

This scheme is perfect, can completely retain the implementation of live event delegate, but the more troublesome is to need more

Write a lot of onclick= "".

In this case there are drawbacks, and finally found a problem can be solved, in the live binding, the element to add style cursor:pointer;

About the iphone Click event is invalid, Android no problem

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.