Wildhoney / EmberDroplet

Ember.js HTML5 file uploading with drag & drop and image/file preview.
http://ember-droplet.herokuapp.com/
MIT License
197 stars 31 forks source link

cannot access JSON response data in uploadFiles callback #95

Closed Leooo closed 8 years ago

Leooo commented 9 years ago

Hello, I tried to follow https://github.com/Wildhoney/EmberDroplet/issues/26 and your code to access the json callback of the request, with:

  actions: {
    uploadFiles: function(){
      //$.when(this._super()).then(function(res){
      this._super().then(function(res){
        log("finished");
        log(res);
      });
    }
  }

but this only sends "undefined", like if the response content was not sent in the callback. Can you explain how to access the response content? Thanks

Wildhoney commented 9 years ago

Are you using the latest version? Because Droplet went through a major refactor lately to make it compatible with Ember 2.0.

If you are, use the hooks property:

App.XDropletComponent = Ember.Component.extend($window.Droplet, {
    url: $window.location.origin + '/upload',
    hooks: {
        didUpload: files => console.log(files)
    }
});
Leooo commented 9 years ago

Thanks. Yes I'm using the last version - though with Ember 1.12.1 as ember-listview is not ready yet for Ember 2.0. This seems to work alright, except for the issue https://github.com/Wildhoney/EmberDroplet/issues/91 which prevents overriding the default options - and probably the didUpload hook too (I see nothing logged when customizing the hook for now).

Leooo commented 8 years ago

the didUpload hook properly gets the data.files object fetched by the server, though it doesn't recognize this (i.e. the component we are working on), which makes it very hard to work on the data (no access to this.store, this.sendAction etc.). I'm talking mostly here about Ember-cli uses, where we are not supposed to use global App.xx stuff.

rupurt commented 8 years ago

@Leooo your issue should be fixed in #100