Fork me on GitHub
#biff
<
2024-04-17
>
jcd18:04:04

anyone had issues with hx-put requests in certain browsers? Several forms I have work in Firefox but fail update in Chrome/Safari. Not sure what the issue is.

jcd19:04:24

It’s not the method… I tried converting it to a POST and that also fails. Other forms are working, so I’ll see if I can figure out what the difference is. (I realize this isn’t an htmx channel, but thought I’d ask anyway 🙂 )

Jacob O'Bryant20:04:11

htmx stuff is definitely relevant 🙂 . might be something up with the CSRF token? that's what I'd look into first.

jcd20:04:52

AFAICT, it's got something to do with how the form tag is handled by Chrome/Safari when inside a tr. I got the request working in an unstyled way by not nesting the inputs... I'll return to making it beautiful later 🙂

👌 1
jcd21:04:37

It looks like this is a limitation of HTML/browsers. Here's a workaround: https://htmx.org/examples/edit-row/

jcd22:04:16

I worked this up and have it working:

(defn form-tr
  [{:keys [hidden] :as opts} & body]
  [:tr (-> (merge {:hx-target "closest tr"
                   :hx-trigger "submit"} opts)
           (dissoc :hidden)
           (assoc-in [:style :margin-bottom] 0))
   [:td.hidden
    (for [[k v] (assoc-some hidden "__anti-forgery-token" anti-forgery/*anti-forgery-token*)]
      [:input {:type "hidden"
               :name k
               :value v}])]
   body])
The UX is not as clean as a form (I need to figure out how to trigger submission on enter, etc.), but it at least works and gets laid out correctly.

👌 1