knownasilya / ember-plupload

Ember component for handling uploads using plupload
MIT License
87 stars 53 forks source link

Bubbling action #67

Closed dant00ine closed 8 years ago

dant00ine commented 8 years ago

Anyone know how to send the file upload action to the route level from child component? Am trying all sorts of different combinations of names, parameters...

Am guessing it has to do with onfileadd? But what's the name of this action in the component?

onfileadd="uploadImage" as |queue dropzone|

this.sendAction('uploadImage', file);

tim-evans commented 8 years ago

Hmm. I think the best way to do this would be to manually bubble up the action as you said. It will call the action with the same name as the one you provided.

dant00ine commented 8 years ago

Tim, thanks for the epic response-time. In the above code the action name is uploadImage then or onfileadd? Having a hard time getting that to trigger with sendAction in the component I am using.

tim-evans commented 8 years ago

I think the following will work:

my-component/template.hbs

{{#pl-uploader onfileadd="bubbleUp"}}
{{/pl-uploader}}

my-component/component.js

import Ember from 'ember';

export default Ember.Component.extend({
  actions: {
    bubbleUp(file) {
      this.sendAction('uploadImage', file);
    }
  }
});