Allow skipping use:enhance
with data-sveltekit-reload
#13180
Labels
feature / enhancement
New feature or request
use:enhance
with data-sveltekit-reload
#13180
Describe the problem
I'm having a search form with multiple fields for various criteria. The table below the form displays the database results correctly filtered. If I click the search button the criteria are correctly updated and so is the result table.
The form is
method="post"
anduse:enhance
and the search button hasformmethod="get"
. The reason is that the same form is also used for form actions (think along the lines of "do this for all filtered items"). And all of this works great so far.Now I need to add a button to export the filtered items. While the fetching from the database takes longer than acceptable I do not want to start a background task, but start downloading the data as soon as it is ready. This works great with a server endpoint that returns a response with a
ReadableStream
and the button havingformtarget="_blank"
but only without JS or without progressive enhancement.Right now it does a fetch request to the target url (overwritten on the export button) but fails at parsing the CSV data as json (
JSON.parse: unexpected character at line 1 column 1 of the JSON data
).Describe the proposed solution
I would like to be able to skip the progressive enhancement with the
data-sveltekit-reload
attribute on either the form element or the form submit element.Alternatives considered
One alternative would be to duplicate each field and sync them with javascript. The duplicate would then be assigned to the export form which would be not enhanced. This does not work w/o js.
Importance
would make my life easier
Additional Information
Putting these lines in
handle_submit
results in the expected behavior:The text was updated successfully, but these errors were encountered: