Skip to content

HTMX extension to send extra parameter on blur event

Notifications You must be signed in to change notification settings

syarul/esc-blur-polyfill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

esc-blur-polyfill

This an extension for HTMX

To use it update your HTML template with

<script src="https://cdn.jsdelivr.net/npm/esc-blur-polyfill@1.0.2/esc-blur-polyfill.js"></script>

Then update element that you wish it to take effect

<input
    class="edit"
    name="title"
    hx-trigger="keyup[keyCode==13], blur"
    hx-get={ fmt.Sprintf(`/update?id=%s`, strconv.FormatUint(action, 10)) }
    hx-target="closest <li/>"
    hx-swap="outerHTML"
    hx-ext="esc-blur-polyfill"
    autofocus
/>

What happen is specific event where ESC key is press will send query parameter &esc=true and false for non-ESC keys. The intention here is to have behavior blur works similar like in modern front-end frameworks where ESC key is excluded from blur event.

About

HTMX extension to send extra parameter on blur event

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published