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.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With