Skip to content

Instantly share code, notes, and snippets.

@bekzod
Forked from ruz/application.controller.js
Last active March 22, 2021 08:58
Show Gist options
  • Save bekzod/59435e6baaabf3798122 to your computer and use it in GitHub Desktop.
Save bekzod/59435e6baaabf3798122 to your computer and use it in GitHub Desktop.
prevent form submit on enter key
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
prevent(e) {
console.log("here we are");
e.preventDefault();
return false;
},
},
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<form onsubmit={{action 'prevent'}} method="POST" action="/test_test_test">
{{input}}
</form>
<br>
<br>
{
"version": "0.4.16",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.1.0",
"ember-data": "2.1.0",
"ember-template-compiler": "2.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment