jaysalvat / ezdz

A jQuery plugin to turn any standard input type file into a nice drag & drop zone with validators and previews.
MIT License
89 stars 36 forks source link

Remove file link #13

Closed ChazyTheBest closed 8 years ago

ChazyTheBest commented 9 years ago

Will this be implemented?

ChazyTheBest commented 8 years ago

I've just created my own code and it's working ok. I won't PR it since it's just a "workaround" out of the script but I'll leave it here for those interested :)

//jquery.ezdz.js#L276
// create the button inside the button container
$ezdz.parent('div').find('div.arrow_box').html('<a class="removeButton">Quitar imagen</a>');
$ezdz.parent('div').find('div.arrow_box').toggleClass('hide');  // show the container
$('body')

// This is just a fancy styling effect for the button container
.on('mouseover', '.removeButton', function() {
    div = $(this).parent().parent();
    div.find('.arrow_box').addClass('ezdz-focus');
})

.on('mouseout', '.removeButton', function() {
    div = $(this).parent().parent();
    div.find('.arrow_box').removeClass('ezdz-focus');
})

// not working in IE, since it's read-only
.on('click', '.removeButton', function() {
    div = $(this).parent().parent();
    div.find('input[type=file]').val('');  // clear the input
    div.children().first().removeClass('ezdz-enter ezdz-accept');  // reset the ezdz container
    div.find('div div').html('Arrastrar imagen');  // reset the ezdz container
    div.find('div.arrow_box').toggleClass('hide');  // hide the link container
});
jaysalvat commented 8 years ago

Thanks. I will try to find some time to add a reset file method soon.

debonx commented 8 years ago

Are there progresses for the remove link feature? Thanks in advance.

jaysalvat commented 8 years ago

Hello.

Please check last version. https://github.com/jaysalvat/ezdz/releases

$('#yourlink').on('click', function () {
    $('input').ezdz('preview', null);
});