Overal EmberJS is a fantastic framework, and we’re very happy with our choice. It’s made developing Matterhorn an enjoyable and for the most part pretty straight forward process.
However, there are times when it is in infuriating! We’re going to try and document all of these issues so you hopefully don’t have to!
An issue which came up recently was how to reopen the text area class so that is allows
cmd/ctrl + enter to save a form.
Options 1 - Initializers
My first thought was to place the code in an initializer. This appeared to be a relatively good solution as it’s auto-loaded by Ember.
However, it has its downsides: Initializers can be run multiple times in test environments
Option 2 - Import
After doing some research I came across a better option, which I’ll be using from now on. It relies on a new folder called app/overrides. This seems to be a better solution as it’s a logical place to store all extensions to EmberJS’s default functionality.
Inside of app/app.coffee you simply add:
`import TextArea from './overrides/textarea';`
The last thing is to change is the textarea, and this stumped me for a bit:
modifiedSubmit allows the text area to save when cmd/ctrl + enter is pressed. And thats it!
Other Useful Resources:
- Stackoverflow: Ember CLI: where to reopen framework classes
- Github Ember Issue
- Medium article: Submit an Ember TextArea with Command or Ctrl + Enter