Skip to content

Htmx extension to refresh hrefs of anchors with the actual URL used for the Ajax call

License

Notifications You must be signed in to change notification settings

jyrimatti/htmx-refresh-href

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

htmx-refresh-href

Htmx extension to refresh hrefs of anchors with the actual URL used for the Ajax call

The refresh-href extension refreshes href attributes of anchor elements having hx-get attribute, with the actual URL used to make the Ajax call.

This enables the browser to show the actual target when hovering the link, and makes "Open link in new tab" work, assuming of course the response is a full document.

Refresh is made by default on "init" (initialization) and "mouseover" events. Events can be changed by listing them in refresh-href -attribute, separated by comma.

bigskysoftware/htmx#1261

Install

<script src="https://unpkg.com/htmx-refresh-href/dist/refresh-href.js"></script>

Usage

<body hx-ext="refresh-href">
  <!-- adds href="/test?param=val" on initialization, and refreshes it onmouseover -->
  <input name="param" value="val" />
  <a hx-get="/test" hx-include="[name='param']">link</div>
</body>

About

Htmx extension to refresh hrefs of anchors with the actual URL used for the Ajax call

Resources

License

Stars

Watchers

Forks

Packages

No packages published