0

I have a dropzone where imagescan be uploaded. After uploading the images, they are also inserted in the database. When the dialog is opened again, it has to load the images from the database and load them in the dropzone.

Currently, I have this:

var myDropzone = Dropzone.forElement("#file_uploader");

if (data.image)
{
    var mockFile = {
        name: 'dds',
        size: 12345,
        type: 'image/' + data.extension,
        status: Dropzone.ADDED,
    };

    // Call the default addedfile event handler
    myDropzone.emit("addedfile", mockFile);

    // And optionally show the thumbnail of the file:
    myDropzone.emit("thumbnail", mockFile, 'images/' + data.image);

    myDropzone.files.push(mockFile);

    $('file_uploader').find('.dz-message').find('SPAN').css('display', 'hidden');

This was just for test (hence the reason why size and name aren't from the loaded image). But when I click 'Remove file', it doesn't fire an event.

In my function which creates the dropzones, it clearly has:

this.on('removedfile', function (file) {...});

And if I upload a new image, the remove file does fire the event. In the event I do an AJAX request which isn't made when I pre-load the images.

I have no clue what's wrong.

Joshua Bakker
  • 2,288
  • 3
  • 30
  • 63
  • removedfile is also an event from dropzone. just do `myDropzone.emit("removedfile", function (file) { condole.log(remove file); });` and see if it fired – nivas Feb 16 '17 at 11:06
  • I'm sorry I might not have explained it well. If I click the "hyperlink" to remove the file, the event won't get called. – Joshua Bakker Feb 16 '17 at 11:22
  • Ref here http://stackoverflow.com/questions/24238193/dropzone-js-to-link-delete-url-with-remove-button this is going to help you to add elements properly – nivas Feb 16 '17 at 12:56

0 Answers0