Skip to content

Commit

Permalink
introduce prevent-default helper
Browse files Browse the repository at this point in the history
  • Loading branch information
DrumsnChocolate committed Nov 5, 2024
1 parent 908199b commit 4d29d7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/components/form/response/response-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
</div>
<div class='card-body'>
<form {{action 'submitResponse' on='submit'}}>
<form {{on 'submit' (prevent-default this.submitResponse)}}>
<Form::Response::ResponseForm @form={{@form}} @response={{@response}} />

<ModelForm::FormActions
Expand Down
10 changes: 10 additions & 0 deletions app/helpers/prevent-default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { helper } from '@ember/component/helper';

export function preventDefault([functionToCall]) {
return function (event) {
event.preventDefault();
functionToCall.apply(this, event, ...arguments);
};
}

export default helper(preventDefault);

0 comments on commit 4d29d7b

Please sign in to comment.