https://github.com/zeecoder/z-hook-finder
Finds JS hooks in a given DOM element, inspired by the BEM methodology.
https://github.com/zeecoder/z-hook-finder
Last synced: 10 months ago
JSON representation
Finds JS hooks in a given DOM element, inspired by the BEM methodology.
- Host: GitHub
- URL: https://github.com/zeecoder/z-hook-finder
- Owner: ZeeCoder
- License: mit
- Created: 2015-06-10T13:38:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-23T21:20:45.000Z (over 10 years ago)
- Last Synced: 2024-04-24T18:10:35.411Z (almost 2 years ago)
- Language: JavaScript
- Homepage:
- Size: 160 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# z-hook-finder
[](https://travis-ci.org/ZeeCoder/z-hook-finder)
[](http://badge.fury.io/js/z-hook-finder)
## What is it
This module was created to handle a [BEM](http://bem.info)-like solution to find JS "hooks".
Here a JS hook means the same for a module as a BEM element means for a block.
As an additional "convention", I use a `js-` prefix for the classnames, which is
used to differenciate JS classes from classes used solely for design by CSS.
## Example, explanations:
```html
```
```js
var HookFinder = require('z-hook-finder');
var finder = new HookFinder($('#js-module'), 'js-module__');
// Alternatively you can pass the separator "__" or something else as the third
// parameter: `new HookFinder($('#js-module'), 'js-module', '__');`
finder.find('button');
// -> returns the jQuery object for the DOM element
finder.find('button', 2);
// -> returns only the first 2 buttons, and outputs a console error
```
Since this is a CommonJS module, it must be used alongside with [Browserify](http://browserify.org/), or
something similar, like [WebPacker](http://webpack.github.io/).
## License
[MIT](LICENSE)