Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Unbinding fastclick #234

Closed
rstacruz opened this issue Mar 29, 2014 · 4 comments
Closed

Unbinding fastclick #234

rstacruz opened this issue Mar 29, 2014 · 4 comments

Comments

@rstacruz
Copy link

Is the an easy way to temporarily unbind fastclick?

I'd love to be able to do this for a few scenarios:

  • Google's places autocomplete doesn't play well with Fastclick, and needsclick isn't a solution that works. I'd like to temporarily disable Fastclick altogether while a Google autocomplete widget is around.
  • I may be using Rails's Turbolinks, and would like fastclick to run only on certain pages. This means it'd have to be unbound once these pages are navigated away from.
@rstacruz
Copy link
Author

#119 is a relevant discussion, by the way — that solution will work for both these use cases.

@matthew-andrews
Copy link
Contributor

You should be able to run .destroy().

So...

var fc = FastClick.attach(document.body);

// Some time later
fc.destroy();

// Re-init
fc = FastClick.attach(document.body);

Alternatively you could use Selective FastClick to more precisely target those elements that are FastClick-safe.

@rstacruz
Copy link
Author

Thanks! I wasn't able to find .destroy() in the docs. Perhaps it should be documented somewhere?

@aghouseh
Copy link

The destroy method is part of the FastClick prototype, so you'll need to save a reference to the FastClick instance and call destroy() on that object.

var fastclick = FastClick.attach(document.body);
...
fastclick.destroy();

I was able to resolve the google maps autocomplete conflict perfectly by using this method.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants