learned hx-trigger

This commit is contained in:
Jonathan 2024-03-16 20:32:35 -05:00
parent ba1b7dca62
commit bb7c69e749
3 changed files with 18 additions and 3 deletions

16
app.lua
View File

@ -4,9 +4,13 @@ local say = require('lua_scripts/main')
app:enable("etlua") app:enable("etlua")
app:post("/clickme", function(self)
self.plane = "P-38L"
return self.plane
end)
app:get("/", function(self) app:get("/", function(self)
self.text = say.hello() self.text = say.hello()
self.plane = { "P-38L" }
return {render = "index"} return {render = "index"}
end) end)
@ -21,6 +25,16 @@ return app

View File

View File

@ -1,5 +1,5 @@
<!-- views/index.etlua --> <!-- views/index.etlua -->
<script src="/path/to/htmx.min.js"></script> <script src="/static/htmx.min.js"></script>
<h1>Hello world</h1> <h1>Hello world</h1>
<p>Welcome to my page</p> <p>Welcome to my page</p>
@ -18,7 +18,8 @@
</form> </form>
<br> <br>
<button>Click me</button> <button hx-post="/clickme" hx-target="#clickable">Click me</button>
<p id="clickable"></p>
<ol> <ol>
<p><% for i, thing in pairs(text) do %> <p><% for i, thing in pairs(text) do %>