| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>My htmx 2 App</title> |
| 5 |
<meta name="htmx-config" content='{"defaultSwapStyle": "outerHTML", "historyCacheSize": 20, "scrollIntoViewOnBoost": true}'> |
| 6 |
<script src="/static/htmx.js"></script> |
| 7 |
<script src="/static/ext/sse.js"></script> |
| 8 |
<script src="/static/ext/ws.js"></script> |
| 9 |
</head> |
| 10 |
<body hx-boost="true" hx-ext="sse, ws"> |
| 11 |
|
| 12 |
<nav hx-target="#main" hx-push-url="true"> |
| 13 |
<a href="/">Home</a> |
| 14 |
<a href="/about">About</a> |
| 15 |
<a href="/contact">Contact</a> |
| 16 |
</nav> |
| 17 |
|
| 18 |
<main id="main"> |
| 19 |
<h1>Dashboard</h1> |
| 20 |
|
| 21 |
|
| 22 |
<div hx-target="#search-results" hx-indicator="#spinner"> |
| 23 |
<input type="search" name="q" |
| 24 |
hx-get="/search" |
| 25 |
hx-trigger="keyup changed delay:300ms"> |
| 26 |
<img id="spinner" class="htmx-indicator" src="/spinner.gif"> |
| 27 |
<div id="search-results"></div> |
| 28 |
</div> |
| 29 |
|
| 30 |
|
| 31 |
<form hx-post="/items" hx-vars="csrf:getToken()" hx-params="not password"> |
| 32 |
<input name="title" required> |
| 33 |
<input name="password" type="password"> |
| 34 |
<button type="submit" hx-disabled-elt="this">Save</button> |
| 35 |
</form> |
| 36 |
|
| 37 |
|
| 38 |
<div hx-confirm="Are you sure?"> |
| 39 |
<button hx-delete="/items/1">Delete Item 1</button> |
| 40 |
<button hx-delete="/items/2">Delete Item 2</button> |
| 41 |
<button hx-delete="/items/3">Delete Item 3</button> |
| 42 |
</div> |
| 43 |
|
| 44 |
|
| 45 |
<div hx-get="/notifications" |
| 46 |
hx-swap="innerHTML show:#notification-area:top" |
| 47 |
hx-trigger="every 30s"> |
| 48 |
</div> |
| 49 |
|
| 50 |
|
| 51 |
<div hx-disable> |
| 52 |
<pre><code>hx-get="/example"</code></pre> |
| 53 |
</div> |
| 54 |
</main> |
| 55 |
|
| 56 |
<aside> |
| 57 |
<div hx-history-elt> |
| 58 |
<div id="sidebar-content"></div> |
| 59 |
</div> |
| 60 |
</aside> |
| 61 |
|
| 62 |
<script> |
| 63 |
htmx.on('htmx:afterSwap', function(e) { |
| 64 |
highlightCode(e.detail.elt); |
| 65 |
}); |
| 66 |
htmx.on('htmx:configRequest', function(e) { |
| 67 |
e.detail.headers['X-CSRF-Token'] = getToken(); |
| 68 |
}); |
| 69 |
htmx.config.globalViewTransitions = true; |
| 70 |
</script> |
| 71 |
</body> |
| 72 |
</html> |