Where to put a call to something.reopen()

Considering the nature of modules and ES6—two things that I know next to nothing about—where should we put calls to reopen() and reopenClass()?

In my particular case, I want to reopen Ember.TextArea so that it calls a jQuery function on itself when it is placed in the DOM. I’ve got it working by placing my code in app/app.js, which seems like the wrong place:

import Ember from 'ember';
import Resolver from 'ember/resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';

Ember.MODEL_FACTORY_INJECTIONS = true;

var App = Ember.Application.extend({
  modulePrefix: config.modulePrefix,
  podModulePrefix: config.podModulePrefix,
  Resolver: Resolver
});

loadInitializers(App, config.modulePrefix);

Ember.TextArea.reopen({
  didInsertElement: function(){
    this.$().elastic();
  }
});

export default App;

I mean it works… but what is the best practice here? And would it be the same for reopenClass()?

I put this stuff in an initializer

...
initializers/preload-store.js
initializers/localise.js
...
/* These alter default behaviour of built-in Ember views */
initializers/ui/text-areas.js
initializers/ui/link-views.js
1 Like

Well… here’s a whole new thing to learn about. :confused:

Thanks for the info! :wink: