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()
?