mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-28 21:41:40 +00:00
better example
This commit is contained in:
parent
2a2fc75c0a
commit
c11b84120d
@ -81,11 +81,6 @@ Autorespond: <input id="autorespond" type="checkbox" onclick="toggleAutoRespond(
|
||||
hx-swap="innerHTML transition:true">Issue Request</button>
|
||||
<h1 id="h1">--</h1>
|
||||
|
||||
<script>
|
||||
this.server.respondWith("GET", "/new-content", function(xhr){
|
||||
xhr.respond(200, {}, "<h1>New Content</h1>")
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@keyframes fade-in {
|
||||
@ -126,6 +121,18 @@ Autorespond: <input id="autorespond" type="checkbox" onclick="toggleAutoRespond(
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var originalContent = htmx.find(".slide-it").innerHTML;
|
||||
|
||||
this.server.respondWith("GET", "/new-content", function(xhr){
|
||||
xhr.respond(200, {}, "<h1>Initial Content</h1> <button hx-get='/original-content' hx-swap='innerHTML transition:true' hx-target='closest div'>Restore It! </button>")
|
||||
});
|
||||
|
||||
this.server.respondWith("GET", "/original-content", function(xhr){
|
||||
xhr.respond(200, {}, originalContent)
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -295,12 +295,6 @@ implement this feature in the near future.
|
||||
|
||||
#### Demo
|
||||
|
||||
<script>
|
||||
this.server.respondWith("GET", "/new-content", function(xhr){
|
||||
xhr.respond(200, {}, "<h1>New Content</h1>")
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@keyframes fade-in {
|
||||
from { opacity: 0; }
|
||||
@ -332,7 +326,6 @@ implement this feature in the near future.
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="slide-it">
|
||||
<h1>Initial Content</h1>
|
||||
<button hx-get="/new-content" hx-swap="innerHTML transition:true" hx-target="closest div">
|
||||
@ -340,6 +333,18 @@ implement this feature in the near future.
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var originalContent = htmx.find(".slide-it").innerHTML;
|
||||
|
||||
this.server.respondWith("GET", "/new-content", function(xhr){
|
||||
xhr.respond(200, {}, "<h1>Initial Content</h1> <button hx-get='/original-content' hx-swap='innerHTML transition:true' hx-target='closest div'>Restore It! </button>")
|
||||
});
|
||||
|
||||
this.server.respondWith("GET", "/original-content", function(xhr){
|
||||
xhr.respond(200, {}, originalContent)
|
||||
});
|
||||
</script>
|
||||
|
||||
#### Conclusion
|
||||
|
||||
You can use the techniques above to create quite a few interesting and pleasing effects with plain old HTML while using htmx.
|
||||
|
Loading…
x
Reference in New Issue
Block a user