How do I change the default file?

Hello

I am using Dropify.js and I want to edit some elements, so when I click on edit an element, the dropify class input works fine, it automatically downloads the given file with this piece of code:

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

      

but when i want to edit another item the file won't change it yet the first one. I hope you can understand me. the elements are in the table. I found this, but I don't 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 anyone can tell me that init () and destroy () and isDropified () functions are executed by exaclty.

+3


source to share


2 answers


I tried this

var nameImage =  img;
$('#edit_profilephoto').dropify({
defaultFile: nameImage,
});

      

And this one



$('#edit_profilephoto').attr('data-default-file', img);

      

they don't work, any known solution please share.

0


source


Here's the 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();

      

0


source







All Articles