Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Circuit8/stimulus-existence

get dom added events and remove elements with Stimulus
https://github.com/Circuit8/stimulus-existence

Last synced: about 2 months ago
JSON representation

get dom added events and remove elements with Stimulus

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.