In Dropzonejs i am creating delete button and then appending it to thumbnails, how can i link url which i am geeting from server directly to remove button by using
Add
addRemoveLinks: true,
then use the following inside
init: function () {}
When you click on dz-remove it goes to it's parent then looks for the text of the span element where the picture id is.
Using $ajax you send that imageId to your action and do what you want. Note: I'm using toastr here for user notifications.
$(".dz-remove").on("click", function (e) {
e.preventDefault();
e.stopPropagation();
var imageId = $(this).parent().find(".dz-filename > span").text();
$.ajax({
url: "Your url here",
data: { imageId: imageId},
type: 'POST',
success: function (data) {
if (data.NotificationType === "Error") {
toastr.error(data.Message);
} else {
toastr.success(data.Message);
}},
error: function (data) {
toastr.error(data.Message);
}
})
});
Hope this helps you bro :)