-
Hi, I have a third-party table component that has a column containing toggle-switch components (status column). Since it's not possible to pass events using props down to the toggle from the table, I'm using a store to save the data of the selected toggle, and bind it to the fields of a form (that will be hidden). The form is bound to a variable (myForm), so when the store.status changes I can programmatically submit the form. Everything works correctly but the problem is that the use:enhance is not used and the page reloads. How can the use:enhance be used when submitting the form programmatically? Here is a simple code to show this behavior +page.svelte
+page.server.js
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Instead of Make sure to check browser support and potentially polyfill before using, though (only Safari 16 or later) |
Beta Was this translation helpful? Give feedback.
-
Thank you @geoffrich! I tried that yesteday on my project but it didn't work and it was even redirecting me to the homepage. But I just tried again and now it's working like a charm! Maybe I just had to restart the server 😅. |
Beta Was this translation helpful? Give feedback.
Instead of
submit
, userequestSubmit
.submit
simply submits the form without running any configured event handlers or custom logic.requestSubmit
will behave the same as if the user submitted the form themselves.Make sure to check browser support and potentially polyfill before using, though (only Safari 16 or later)