Getting context inside callback


#1

I’m trying to do what the Op was asking here: https://github.com/FutoRicky/ember-cli-dropzonejs/issues/12

But when i do this i get errors inside dropzone here: https://github.com/enyo/dropzone/blob/master/dist/dropzone.js#L58 saying that callback is null.

How can i get the components context inside the callback? that’s all I want to do - seems like this should be simpler but i’ve been spinning my wheels for a good hour on this - could just be me to be fair :slight_smile:


#2

Anyone?! :stuck_out_tongue:

Surely this is a standard thing that people need to do?


#3

Closure actions will preserve the context.

{{drop-zone url="http://localhost/upload" success=(action 'uploadSuccess')}}
export default Ember.Component.extend({
  foo: 'bar',
  actions: {
    uploadSuccess() {
      console.log(this.foo);
    }
  }
});

#4

Yeah that works :slight_smile: cheers