Closed ckald closed 1 year ago
Hmmm... I agree that detecting Content-Disposition
would be nice, but I'm thinking if there is a way to handle that simpler than with a click on button. Honestly this feels like too much code for an issue like that.
Htmx decided to just ignore the issue: https://github.com/bigskysoftware/htmx/issues/474
They say it is complicated for them. It seems to work for me 🤷 They advise to turn off htmx for such a form -- but we are implementing a form that either validates or generates a file. I think it's a normal use case. Implementing this endpoint in other way would probably require to store the file on disk, which will require lots of additional backend code.
I don't know of another way to download the XHR response using JS. Data-urls are not that well supported.
Yeah it makes sense if you generate file during the http request... Let me think about it a bit.
Sorry, after thinking about this, I decided against inclusion of code for handling this case. What I can propose instead is maybe reworking backend to handle this, or adding an extension point so it could be done with a bit of custom js.
We were implementing an endpoint that validates a form and generates a file. Turns out, twinspark could not handle
Content-Disposition
headers and always requires the HTML response.I've implemented a simple workaround that automatically detects
Content-Disposition
and stops the request handling. Also I added a way to override this behavior or download the response content that does not come withContent-Disposition
.We do not work with complicated batched requests, so please take a look if this makes sense?