mysterious-toddler-20573
11/08/2022, 2:14 PMmysterious-toddler-20573
11/08/2022, 2:14 PMmysterious-toddler-20573
11/08/2022, 2:14 PMbillions-lion-37063
11/08/2022, 2:21 PMmysterious-toddler-20573
11/08/2022, 2:23 PMmysterious-toddler-20573
11/08/2022, 2:23 PMmysterious-toddler-20573
11/08/2022, 2:23 PMmysterious-toddler-20573
11/08/2022, 2:23 PMrhythmic-hydrogen-92496
11/08/2022, 2:28 PMpowerful-helmet-42757
11/08/2022, 2:56 PMnarrow-room-51024
11/08/2022, 2:59 PMpowerful-helmet-42757
11/08/2022, 2:59 PMmysterious-toddler-20573
11/08/2022, 2:59 PMmysterious-toddler-20573
11/08/2022, 3:00 PMpowerful-helmet-42757
11/08/2022, 3:02 PMastonishing-barista-36240
11/08/2022, 3:02 PM<div hx-trigger="keydown[key=='Escape']" hx-get=".."><input hx-trigger="focusout, keydown[key=='Enter']" hx-post=".."/></div>
. The idea is to have a quick single text input that posts its value when it loses focus or enter is pushed in it, and when the user presses Escape, the edit should be canceled (and the whole div swapped out for the non-edit-input fragment). But the problem with this is that, when I push Escape, the GET is called, but then the POST is called too (presumably from the focus out).powerful-helmet-42757
11/08/2022, 3:04 PMhtmx.ajax('GET', '/a', {swap: "none"})
then setAttribute with whatever value I gotrhythmic-hydrogen-92496
11/08/2022, 3:14 PMmysterious-toddler-20573
11/08/2022, 4:16 PMfetch()
and being done with it is less complicatedpowerful-helmet-42757
11/08/2022, 4:19 PMfetch()
way.
It's a small web-component that already does some stuff, and updating the should also add an attribute to the body
.
Doing everything server side and updating the whole thing every seconds is a bit too muchmysterious-toddler-20573
11/08/2022, 4:20 PMjs:
prefix in the swap that allows you to call an arbitrary javascript functionmysterious-toddler-20573
11/08/2022, 4:21 PMhtml
<button hx-get="/whatever"
hx-swap="js:doSomething(response)">
Do Something
</button>
powerful-helmet-42757
11/08/2022, 4:21 PMmysterious-toddler-20573
11/08/2022, 4:21 PMjs
prefix in other placesastonishing-barista-36240
11/08/2022, 5:00 PMwhite-motorcycle-95262
11/08/2022, 5:32 PMTypeError: ajaxHelper(...) is undefined
error when returning a response with an HX-Location
header. Any ideas?
EDIT: Seems to be related to using HX-Location to redirect to a view that also returned a HX-Location redirect. I have a checkout/
URL that determines which step of the process they are in and uses HX-Location to redirect to checkout/<step>
. There's also a way for the user to log in on the checkout page, and logging in redirected them to the checkout/
URL that then redirected to checkout/payment
. If I simply have the login view use HX-Location to checkout/payment
, it works. 🤷mysterious-toddler-20573
11/08/2022, 6:21 PMmysterious-toddler-20573
11/08/2022, 6:33 PMmysterious-toddler-20573
11/08/2022, 6:33 PMhtml
<input _="on focus or htmx:afterRequest
set :initial_value to my value
on keyup[key=='Escape']
set my value to the :initial_value then
blur() me"
hx-post="/sample"
hx-trigger="change, keyup[key=='Enter']"
hx-target="next output"
type="text" name="foo" value="asdf"/>
<output>--</output>
mysterious-toddler-20573
11/08/2022, 8:00 PM