Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 716 Bytes

README.md

File metadata and controls

25 lines (17 loc) · 716 Bytes

hash-select

Specify HTMX select attribute using the URL fragment identifier. I encourage reading the source hash-select.js since it contains only 4 significant lines of code. Summarized, if an HTMX request path is given with a fragment identifier #some-id, then this extension will override hx-select with the selector #some-id.

Usage

Load the extension after loading HTMX:

<script src="https://unpkg.com/htmx-ext-hash-select"></script>

Then,

<button hx-post="endpoint#status" hx-swap="outerHTML">Click for Status</button>

Becomes approximately equivalent to

<button hx-post="endpoint#status" hx-select="#status" hx-swap="outerHTML">Click for Status</button>