Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change default file dropify?

Hello

I am using Dropify.js, and I want to edit some items, so when I click to edit an item, the input with dropify class works fine it upload automatically the given file with this part of code:

  $('.dropify').dropify({
            defaultFile: app.getPath('userData') + '/images/' + doc.image
          });

but when I want to edit another item, the file doesn't change it still the first one. I hope you understund me. items are in a table. I found this but I dont know how to do it:

 var drDestroy = $('.dropify').dropify();
                drDestroy = drDestroy.data('dropify')
                $('#toggleDropify').on('click', function(e){
                    e.preventDefault();
                    if (drDestroy.isDropified()) {
                        drDestroy.destroy();
                    } else {
                        drDestroy.init();
                    }
                }) 

if any one can tell me what init() and destroy() and isDropified() functions do exaclty.

like image 861
mosab Avatar asked Jun 15 '17 15:06

mosab


1 Answers

Here is a solution:

var imagenUrl = "";
var drEvent = $('#yourInputFileId').dropify(
{
  defaultFile: imagenUrl
});
drEvent = drEvent.data('dropify');
drEvent.resetPreview();
drEvent.clearElement();
drEvent.settings.defaultFile = imagenUrl;
drEvent.destroy();
drEvent.init();
like image 176
Gonzalo Bustamante Avatar answered Oct 02 '22 13:10

Gonzalo Bustamante