question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reactivity in on:submit is not working as expected

See original GitHub issue

Describe the bug I am not seeing my error message when I click the button with an empty input field.

To Reproduce First REPL where you see the expected behavior: https://svelte.dev/repl/27fea1d7bd10434eacc89606ad15ff8c?version=3.12.1 Load the page, hit the button, see the error message

Second REPL that shows how I actually want my code to be: https://svelte.dev/repl/de196c90bd834266bf78d7f686eb0802?version=3.12.1 Load the page, hit the button, no error message. Type in the input, the error message shows up

Expected behavior The second REPL should work. Alternatively, if I could somehow bind the this for the on:submit function would that make this problem go away (e.g. is the static fn callstack somehow causing this problem)?

What do I need to change, or is there a bug, why my second example doesn’t work?

Severity This is a considerable issue in writing re-usable JS in projects.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jobelenuscommented, Nov 1, 2019

OK, I was able to make it work with set/getContext —> https://svelte.dev/repl/aec39420455e495cbf1c27471885e364?version=3.12.1

However, if I may be so bold, I noticed I cannot bind to a variable declared with the let:directive. I can understand why that would be a giant mess. However, it means I would have to create components for each tag I want to bind a value to. It means a lot of boilerplate, which is something I can live with — but I am wondering what the easiest way to allow all the html attributes (type, class, style, data-…) through the component props without having to type them all out (which, with data attrs could literally be endless)?

0reactions
jobelenuscommented, Nov 1, 2019

How “bad” would it be to use $$props within <Input> to grab everything? (Imagine there are a lot of <Input>'s)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reactive form not called onsubmit - Stack Overflow
The problem is that it doesn't call the onSubmit method and I don't know why. Can anyone help me? angular · forms ·...
Read more >
submit() on form element doesn't trigger onSubmit · Issue #6796
If I have a ref to the form DOM element and call submit() on it, it does not trigger the onSubmit callback. ......
Read more >
OnSubmit client script not working as expected - ServiceNow
I have a requirement to create onSubmit client for the date field. If the new date is less than 61 days from todays...
Read more >
Handling Forms in Svelte - This Dot Labs
Our form is working as expected. However, I'd like to move it to a new component. Creating a reusable form component. Let's create...
Read more >
OnSubmit event not fired when trying to submit invalid form
What steps will reproduce the problem? 1. Create some HTML5 form with required/validated fields. 2. Add onsubmit handler to form. 3. Try to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found