Skip to content

Commit bd654e2

Browse files
committed
Update fasthtml examples to actually work with rc.6
1 parent a67237c commit bd654e2

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

examples/fasthtml/advanced.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def index():
112112
Div(cls="container")(
113113
Section(
114114
H2("Demonstration: Long-lived GET Request to Generator Function"),
115-
Div(data_on_load=f"@get('{time}')", cls="time")(
115+
Div(data_init=f"@get('{time}')", cls="time")(
116116
"Current time from element: ",
117117
Span(id="currentTime")(now),
118118
),
@@ -133,16 +133,18 @@ def index():
133133
),
134134
),
135135
# When the below request is in flight, $filtering becomes true, setting the aria-busy attribute
136-
Label(fr="filter", data_attr_aria_busy="$filtering")("Filter Compound"),
136+
Label({"data-attr:aria-busy": "$filtering"}, fr="filter")("Filter Compound"),
137137
# Bind the 'filter' signal to the value of this input, debouncing using Datastar modifier
138138
Input(
139-
{"data-on:input__debounce.250ms": f"@post('{table}')"},
140-
data_bind_filter=True,
139+
{
140+
"data-on:input__debounce.250ms": f"@post('{table}')",
141+
"data-bind:filter": True,
142+
"data-indicator:filtering": True,
143+
},
141144
id="filter",
142145
name="filter",
143-
data_indicator_filtering=True,
144146
),
145-
Div(id="gt-table", data_on_load=f"@post('{table}')"),
147+
Div(id="gt-table", data_init=f"@post('{table}')"),
146148
),
147149
),
148150
)
@@ -175,11 +177,13 @@ async def _():
175177
async def reset():
176178
reset_and_hello = Div(id="myElement")(
177179
Button(
178-
data_on_click=f"@get('{hello}')",
180+
{
181+
"data-on:click": f"@get('{hello}')",
182+
"data-indicator:resetting": True,
183+
"data-attr:aria-busy": "$resetting",
184+
"data-attr:disabled": "$resetting",
185+
},
179186
type="reset",
180-
data_indicator_resetting=True,
181-
data_attr_aria_busy="$resetting",
182-
data_attr_disabled="$resetting",
183187
)("Reset"),
184188
Div("Hello!"),
185189
)
@@ -194,10 +198,12 @@ async def _():
194198
# Define the button once so that it can be used in the index response
195199
HELLO_BUTTON = Div(id="myElement")(
196200
Button(
197-
data_on_click=f"@get('{reset}')",
198-
data_indicator_loading=True,
199-
data_attr_aria_busy="$loading",
200-
data_attr_disabled="$loading",
201+
{
202+
"data-on:click": f"@get('{reset}')",
203+
"data-indicator:loading": True,
204+
"data-attr:aria-busy": "$loading",
205+
"data-attr:disabled": "$loading",
206+
}
201207
)("Say hello"),
202208
)
203209

examples/fasthtml/simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async def index():
4141
example_style,
4242
Body(data_signals=json.dumps({"currentTime": now}))(
4343
Div(cls="container")(
44-
Div(data_on_load="@get('/updates')", cls="time")(
44+
Div(data_init="@get('/updates')", cls="time")(
4545
"Current time from element: ",
4646
Span(id="currentTime")(now),
4747
),

0 commit comments

Comments
 (0)