Skip to content

Commit 749ab7f

Browse files
committed
feat: add htmx-2 app demo
1 parent f71172a commit 749ab7f

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ steps.
66
* [Angular 17](./angular-17/)
77
* [Angular 21](./angular-21/)
88
* [Hono 4](./hono-4/)
9+
* [Htmx 2](./htmx-2/)
910
* [Lit 3](./lit-3/)
1011
* [Preact 10](./preact-10/)
1112
* [Remix 3](./remix-3/)

htmx-2/index.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Buildless htmx 2 app</title>
6+
<meta name="htmx-config" content='{"selfRequestsOnly":false}' />
7+
<style>
8+
#users.htmx-request,
9+
#posts.htmx-request,
10+
.loading-users:not(.htmx-request),
11+
.loading-posts:not(.htmx-request) {
12+
display: none;
13+
}
14+
</style>
15+
<script src="https://unpkg.com/htmx.org@2.0.8"></script>
16+
<script src="https://unpkg.com/htmx-json@1.9.6"></script>
17+
</head>
18+
<body hx-ext="json-swap">
19+
<h1>Buildless htmx 2 app</h1>
20+
<label
21+
id="users"
22+
hx-get="https://jsonplaceholder.typicode.com/users"
23+
hx-trigger="load"
24+
hx-swap="json"
25+
hx-target="#users, #posts-status"
26+
hx-indicator="#users, .loading-users"
27+
>
28+
Select User:
29+
<select
30+
name="userId"
31+
hx-get="https://jsonplaceholder.typicode.com/posts"
32+
hx-swap="json"
33+
hx-target="#posts"
34+
hx-indicator="#posts, .loading-posts"
35+
>
36+
<option hidden selected></option>
37+
<template json-each="$this" json-key="id">
38+
<option @value="id">@${username}: ${name}</option>
39+
</template>
40+
</select>
41+
</label>
42+
<p class="loading-users">Loading Users...</p>
43+
<ul id="posts">
44+
<template json-each="$this" json-key="id">
45+
<li>${title}</li>
46+
</template>
47+
</ul>
48+
<p class="loading-posts">Loading Posts...</p>
49+
</body>
50+
</html>

0 commit comments

Comments
 (0)