fast-nest-2846
09/03/2021, 3:44 PMmysterious-toddler-20573
09/03/2021, 3:44 PMx-on:?mysterious-toddler-20573
09/03/2021, 3:44 PMfast-nest-2846
09/03/2021, 3:44 PMmysterious-toddler-20573
09/03/2021, 3:46 PMfast-nest-2846
09/03/2021, 3:46 PMmysterious-toddler-20573
09/03/2021, 3:46 PMNote that all events are fired with two different names
Camel Case
Kebab Case
So, for example, you can listen for htmx:afterSwap or for htmx:after-swap. This facilitates interoperability with libraries like Alpine.js.mysterious-toddler-20573
09/03/2021, 3:46 PMgorgeous-airport-54386
09/03/2021, 3:47 PMfast-nest-2846
09/03/2021, 3:47 PMmysterious-toddler-20573
09/03/2021, 3:48 PMfast-nest-2846
09/03/2021, 3:49 PMfreezing-crowd-50703
09/03/2021, 3:51 PMmysterious-toddler-20573
09/03/2021, 3:52 PMfast-nest-2846
09/03/2021, 3:52 PMfast-nest-2846
09/03/2021, 3:52 PMfast-nest-2846
09/03/2021, 4:02 PMfast-nest-2846
09/03/2021, 4:16 PM<input
_="on htmx:afterRequest put '' into #new-todo.value"
id="mon"
hx-include="#new-todo"
th:hx-post="@{/public/todo/create}"
hx-target="#todo-list"
hx-swap="beforeend"
hx-trigger="click"
type="button" class="btn btn-primary" value="Add"/></td>
Translates to this for me now with AlpineJS
<div id="input-area" x-data>
<input x-ref="nameInput" id="new-name" name="new-name" placeholder="New name..." required type="text"/>
<button hx-include="#new-name" th:attr="hx-post=@{/create}"
hx-target="#collection" hx-trigger="click" hx-swap="beforeend"
@htmx:after-request.window="
if( $event?.detail?.xhr?.status === 200 ) {
$refs.nameInput.value = ''
}
">Add
</button>
</div>
`mysterious-toddler-20573
09/03/2021, 4:19 PMhtml
<input _="on htmx:afterRequest(status)
put '' into #new-todo's value unless the status is not 200"
id="mon"
hx-include="#new-todo"
th:hx-post="@{/public/todo/create}"
hx-target="#todo-list"
hx-swap="beforeend"
type="button"
class="btn btn-primary" value="Add"/></td>mysterious-toddler-20573
09/03/2021, 4:19 PMfast-nest-2846
09/03/2021, 4:19 PMmysterious-toddler-20573
09/03/2021, 4:20 PMmysterious-toddler-20573
09/03/2021, 4:20 PMfast-nest-2846
09/03/2021, 4:22 PMmillions-island-74338
09/03/2021, 7:17 PM<form hx-post="edit" hx-target="#messages" id="editor-save">
<input id="contents" name="contents" value="Monaco Contens" type="hidden">
<button _="on click call monacoEditor.getValue() then put it into #contents.value">Save</button>
</form>
This works great!
The question is, how do I add keybindings for Ctrl-S to save the contents as well?
monaco has a keybinding api I can hook into, but when I manually run "#editor-save button.click()" the the hyperscript doesn't seem to get triggered.
What would y'all recommend?gorgeous-airport-54386
09/03/2021, 7:18 PMeditor-save-button?millions-island-74338
09/03/2021, 7:21 PMmysterious-toddler-20573
09/03/2021, 7:40 PMmysterious-toddler-20573
09/03/2021, 7:42 PMmontiorEvents trick outlined here: https://htmx.org/docs/#debugging