I like your opinion on this pattern. I wanted to be able to call focus function on a component from my controller, the way I implemented it was a reference to of itself by an action defined on the controller then call the method on it. It works fine just wondering if some sort anti-pattern I should stay away from?
<button </button>
// x-input.js
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super();
if (!Ember.isNone(this.get('bindingAction')) {
this.get('bindingAction')(this)
}
}
focus() {
// focus on component.
}
});
// controller.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
bindInput(input) {
this.set('input', input);
}
focusOnInput() {
this.get('input').focus();
}
}
});
Aucun commentaire:
Enregistrer un commentaire