Fastclick plugin causes date (input[type= "date"]) control cannot be triggered how to resolve _javascript tips

Source: Internet
Author: User

This article as a novice, write a bad place also please everyone a lot of advice, the following content is just for everyone to encourage the following my solution, but also a personal opinion of me, have different opinions of different solutions friends also please share their solutions.

First of all, we use the Fastclick plug-in's original intention is to solve the "tap" event "point through" bug;fastclick and tap are using the "touch" event to simulate the "click" event;

Then we'll get a general idea of how Fastclick works (from the copy on):

Track all Touchstart events in our app, triggering a click event when a Touchend event is received;

The use of methods can be found Niang;

But the problem, when the use of Fastclick, we found that the "date" control can not be triggered, is a normal click can not be triggered, if the length of the 0.5S is still able to trigger, but the problem has already existed, must be resolved!

By reading Fastclick's source, there's a way to find it.

Anyway, the meaning mentioned above, is to accept the Touchend event, triggering a click event;

So my solution is to:

When touchend we judge his event.target exactly is what, if it is date we do not play, do not you fastclick, with the original to trigger not OK, to a return false;

My Code:

Here if the conditions are casually written slightly, according to the requirements of the project, you want to be to arrive at a special condition when you quit on the good;

This article as a novice, write a bad place also please everyone a lot of advice, the following content is just for everyone to encourage the following my solution, but also a personal opinion of me, have different opinions of different solutions friends also please share their solutions. Thank you for your attention to this article, with your support I will do better.

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.