I wrote an Ember component that represents a styled input field that can handle file uploads.
In order to achieve this I used a <div>
and an <input>
. The <input>
has visibility: hidden
and once the click event on the <div>
is fired I fire the click event on the invisible <input>
in the action handling of the Ember component.
My problem is that after choosing files the action never reaches my Ember component.
add-document-input.hbs
<div {{action "add"}} class="floating-button">
<span>+</span>
</div>
{{input multiple="true" action="upload" on="change" accept="image/png,image/jpeg,application/pdf" type="file"}}
add-document-input.js
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
upload() {
console.log('This never happens');
},
add() {
Ember.$("input[type='file']").click();
}
}
});
I guess that it has something to do with me triggering the click event within the action. That way the second time an action happens in the view it does not get to the component.
Ember version: 2.7.0