mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-10-03 07:45:21 +00:00
improve demo: https://github.com/bigskysoftware/htmx/issues/62
This commit is contained in:
parent
0431d548fb
commit
5d04b56c11
@ -87,7 +87,7 @@ Below is a working demo of this example. The only email that will be accepted i
|
|||||||
|
|
||||||
// routes
|
// routes
|
||||||
init("/demo", function(request, params){
|
init("/demo", function(request, params){
|
||||||
return formTemplate();
|
return demoTemplate();
|
||||||
});
|
});
|
||||||
|
|
||||||
onPost("/contact", function(request, params){
|
onPost("/contact", function(request, params){
|
||||||
@ -106,8 +106,13 @@ Below is a working demo of this example. The only email that will be accepted i
|
|||||||
});
|
});
|
||||||
|
|
||||||
// templates
|
// templates
|
||||||
function formTemplate(page) {
|
function demoTemplate() {
|
||||||
return `<h3>Signup Form</h3><form hx-post="/contact">
|
|
||||||
|
return `<h3>Signup Form</h3><p>Enter an email into the input below and on tab out it will be validated. Only "test@test.com" will pass.</p> ` + formTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formTemplate() {
|
||||||
|
return `<form hx-post="/contact">
|
||||||
<div hx-target="this" hx-swap="outerHTML">
|
<div hx-target="this" hx-swap="outerHTML">
|
||||||
<label>Email Address</label>
|
<label>Email Address</label>
|
||||||
<input name="email" hx-get="/contact/email" hx-indicator="#ind">
|
<input name="email" hx-get="/contact/email" hx-indicator="#ind">
|
||||||
@ -121,7 +126,7 @@ Below is a working demo of this example. The only email that will be accepted i
|
|||||||
<label>Last Name</label>
|
<label>Last Name</label>
|
||||||
<input type="text" class="form-control" name="lastName">
|
<input type="text" class="form-control" name="lastName">
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-default">Submit</button>
|
<button class="btn btn-default" disabled>Submit</button>
|
||||||
</form>`;
|
</form>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user