Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanburnette/bind-click
A function to bind the click event with a couple of common problems worked out.
https://github.com/ryanburnette/bind-click
Last synced: 22 days ago
JSON representation
A function to bind the click event with a couple of common problems worked out.
- Host: GitHub
- URL: https://github.com/ryanburnette/bind-click
- Owner: ryanburnette
- License: isc
- Created: 2018-02-01T16:29:31.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-17T22:28:14.000Z (almost 6 years ago)
- Last Synced: 2024-12-19T20:26:33.561Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 75.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# bind-click
Attach a function to the click event while handling some edge cases that I like
to address.## Notes
- Pass in a Node, NodeList, or a string to select the target element
- Fails gracefully if no elements are selected
- If a string selector is passed in, the DOM is queried each time giving a "jQuery live"-ish behavior
- Default event is click
- Solves [click issue on some older iOS touch screens][1]## Basic Usage
```javascript
bindClick(document.querySelectorAll('.button'),function (e) {
console.log(e);
});
```## Requirements
- Solving [this issue][1] requires the [Modernizr with the touchevents detect](https://modernizr.com/download?touchevents-setclasses&q=touchev) and `setClasses` enabled
[1]: https://bugs.jquery.com/ticket/5677