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.

performing via onsubmit not working?

See original GitHub issue

Is it just me or is performing a task via an onsubmit on a form not working? But an action that then calls perform works.

Does not work:

<form onsubmit={{perform createApp}}>

Works:

actions: {

  createApp: function() {
    this.get('createApp').perform();
  }

}
<form {{action "createApp" on="submit"}}>

Issue Analytics

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

github_iconTop GitHub Comments

12reactions
mmuncommented, Mar 23, 2016

Defining an onsubmit does not prevent the default behaviour from occurring. You’ll need to call event.preventDefault() to get this behaviour.

Alternatively, just use <form {{action (perform createApp) on='submit'}}> which does preventDefault by default.

7reactions
theseyicommented, Mar 15, 2018

Maybe add this to the FAQ? @machty Almost a year later and found this useful

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript onsubmit not working - Stack Overflow
My problem, I had without knowing a form inside a form I was interacting with the inner one no matter what I do...
Read more >
Onsubmit not working! - JavaScript - SitePoint Forums
My onsubmit function is not working. My PHP file has two forms. Both form tags have an onsubmit attribute that links to the...
Read more >
javascript - onsubmit is not working in form [SOLVED] - Daniweb
I want to validate my form so i call validateForm() using onsubmit of the form. It displays the alert but doesn't cancel the...
Read more >
How to type a React form onSubmit handler
So we're telling TypeScript that event.currentTarget is an HTMLFormElement but then we immediately tell TypeScript that this isn't quite right by using as...
Read more >
Onsubmit catalog client script not working properly - ServiceNow
Yeah that is because, the onsubmit cline script will only when there is a submit action performed on the portal. I would suggest...
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