https://github.com/Circuit8/stimulus-existence
get dom added events and remove elements with Stimulus
https://github.com/Circuit8/stimulus-existence
Last synced: 5 months ago
JSON representation
get dom added events and remove elements with Stimulus
- Host: GitHub
- URL: https://github.com/Circuit8/stimulus-existence
- Owner: Circuit8
- Created: 2020-06-23T15:21:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T17:03:11.000Z (almost 3 years ago)
- Last Synced: 2024-11-17T01:32:35.524Z (11 months ago)
- Language: JavaScript
- Size: 1.18 MB
- Stars: 11
- Watchers: 3
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Stimulus Existence
Stimulus controller to remove elements from the dom, and be notified with an event when they are added.
## Installation
```shell
$ yarn add stimulus-existence
```## Usage
Register the controller with Stimulus:
```javascript
// application.js
import { Application } from "stimulus";
import { ExistenceController } from "stimulus-existence";const application = Application.start();
application.register("existence", ExistenceController);
```Initialize the controller on a container element, use the `remove()` action to delete the entire container. Listen to `existence:added` events to discover when your container has been added to the dom. Useful for Rails Ujs Dom HTML additions, and hooking up with other controllers.
```html
Close me
```## Contributing
Fork the project.
Install dependencies
```shell
$ yarn install
```Write some tests, and add your feature. Send a PR.