-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access Dropzone within callback #26
Comments
I also had the same problem like you. I found a solution that may not be beautiful, but it works. My component looks like this:
So to sum it up, i set an id to the dropzone element and wait until my parent component got inserted into the DOM. Now you can access the instance of the dropzone with this.get('dropzone') and execute every method on it. P.S.: JSHint may complain about Dropzone not being available but it is global. So you can set it as predef in .jshintrc like this: |
@mrukas Nice. I will give that a try. Thanks for the advice. |
@mrukas Wanted to let you know your solution worked perfectly. You're a lifesaver. Thanks for taking the time to post the workaround. |
Hello, I tried your solution @mrukas but I have an issue. DropZone is not happy he tell me : |
Hey! Is it possible that you forgot to give the component an id? In my example the id was "fileUpload" but you can choose whatever you want. This is the way you use the component. And in the other component where you used the dropzoine you have to change the line in the didInsertElement method like this: |
Indeed ^^. |
There is a much easier way to achieve this: Template {{drop-zone url='{your-url}' success=onDropzoneSuccess}} Controller import Ember from 'ember';
export default Ember.Controller.extend({
onDropzoneSuccess(file) {
this.removeAllFiles(); //the `this` keyword points to the dropzone object!
// or this.removeFile(file);
}
}); NB. |
That is the correct way of doing it. |
Thanks again for your great work on this project.
There seems to be no way to access dropzone in the callbacks in which only a File object is passed.
For example, if I want to clear the Dropzone display of all existing files in an onSuccess method, there is no way to do it -- at least that I can find.
Keep up the great work!
The text was updated successfully, but these errors were encountered: