gorgeous-ghost-95789
03/07/2023, 6:58 PMtall-dinner-62086
03/07/2023, 10:32 PMrapid-umbrella-80895
03/08/2023, 12:12 AMrefined-waiter-90422
03/08/2023, 5:41 AMbillions-solstice-65074
03/08/2023, 5:52 AMbillions-solstice-65074
03/08/2023, 5:52 AMenough-petabyte-50314
03/08/2023, 6:21 AMfreezing-waitress-26396
03/08/2023, 8:52 AMfreezing-waitress-26396
03/08/2023, 8:54 AMsessionStorage
existshappy-knife-63802
03/08/2023, 5:16 PMhappy-knife-63802
03/08/2023, 7:03 PMhappy-knife-63802
03/08/2023, 7:03 PMhappy-knife-63802
03/08/2023, 7:03 PMlate-king-98305
03/08/2023, 7:09 PMhtmx:afterSwap
for initializing your new stuff.
This is what I wrote up about my page-level vs. htmx init findings: https://bitbadger.solutions/blog/2023/page-level-javascript-initialization-with-htmx.htmlhappy-knife-63802
03/08/2023, 7:09 PMlate-king-98305
03/08/2023, 7:11 PMhtmx:afterSwap
but the code actually uses htmx:afterSettle
. Let me know what you find - I may need to edit my post!happy-knife-63802
03/08/2023, 7:12 PMlate-king-98305
03/08/2023, 7:15 PMhtmx:afterSwap
fires; I'm trying to remember why I ended up using htmx:afterSettle
, but that code was a copy/paste from the project where I used it.happy-knife-63802
03/08/2023, 7:15 PMlate-king-98305
03/08/2023, 7:19 PMhappy-knife-63802
03/08/2023, 7:20 PMhappy-knife-63802
03/08/2023, 7:21 PMlate-king-98305
03/08/2023, 7:22 PMhappy-knife-63802
03/08/2023, 7:23 PMlate-king-98305
03/08/2023, 7:24 PMhappy-knife-63802
03/08/2023, 7:24 PMmagnificent-camera-86904
03/09/2023, 6:39 AMtextarea
to trigger an htmx request when the user presses enter?
This is what I have so far:
html
<form id="chatbox-submit">
{% csrf_token %}
<textarea id="question-text-area" hx-trigger="keyup"></textarea>
</form>
I tried hx-trigger="enter"
and Enter
but neither worked.
I don't see any examples of using keys in the HTMX docs
https://htmx.org/docs/#triggers
Bonus, It would be nice if it only submitted when the user presses Enter, but not Shift+Enter. This is how I know to do it in JS
js
const node = chatBox.querySelector("textarea");
node.addEventListener("keyup", ({ key, shiftKey }) => {
if (key === "Enter" && !shiftKey) {
// Do things
}
});
I asked a related question awhile back and I solved it because it seemed like the browser knew that hitting enter was 'submit' ...but that was when I was using an input element. Things broke when I started using textarea
https://discord.com/channels/725789699527933952/725789747212976259/1079989023482855494ripe-action-67367
03/09/2023, 6:59 AM