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

https://github.com/knowler/log-form-element

A custom element that will log a form’s submissions to the console.
https://github.com/knowler/log-form-element

custom-elements web-components

Last synced: 11 months ago
JSON representation

A custom element that will log a form’s submissions to the console.

Awesome Lists containing this project

README

          

# ``: Log Form element

@knowler/log-form-element on JSR

Wrap a `` element with this `` element and when submitted,
instead of using the default action, it’ll log the form data to the console.

## Usage

The element is published on [JSR][] (which can be used as an NPM registry) or
you can use a CDN like [esm.sh][] to import the module.

By default, the module exports the class for you to define yourself. The class
has a `define()` method which can be used to easily define the element either
using a default tag name of `log-form` or whatever one you pass it.

```javascript
import { LogFormElement } from "https://esm.sh/jsr/@knowler/log-form-element";

LogFormElement.define();
```

You can also add a `?define` search param to the module’s URL which it’ll use to
automatically register the custom element using the default tag name. If you are
using a CDN, you might need to add a `?raw` param so that the `define` param
applies to module URL itself.

```html

```

Once the element is registered. You can wrap `` elements with it and then
open your console to debug submission.

```html


Pizza toppings
Submit

```

## Examples

- [Basic](https://knowler.github.io/log-form-element/examples/basic)
- [Auto-define](https://knowler.github.io/log-form-element/examples/auto-define)

[JSR]: https://jsr.io/
[esm.sh]: https://esm.sh/
[jsr:@knowler/log-form-element]: https://jsr.io/@knowler/log-form-element