I am creating a website where clicking on a button opens a Modal window where it shows a series of images.
In each of those images there are the download and delete buttons.
By clicking on delete I do not know how to make that image disappear, that is, recharge the content of the modal.
The jquery code:
$('.btn-image-library').click(function() {
var cod = $('#editCodi').val();
var src = $( this ).closest('.box-image-library').find('.image-library').attr('src');
var action = $( this ).text();
var filename = $( this ).closest('.box-image-library').find('.text-descripcio-image-library').text();
if (action == 'delete'){
// Delete image
$.ajax({
url:"deleteImagesManageProduct.php",
type:"POST",
data:{"filename": filename, "codigo": cod},
dataType:"text",
success:function(data){
// AQUÍ ACTUALIZAR CONTENIDO MODAL ¿?
}
});
}
});
The HTML code of the Modal window:
<!-- MANAGE IMAGES MODAL MENU -->
<div class="modal fade" id="manageImagesProduct" tabindex="-1" role="dialog" aria-labelledby="change" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
<h4 class="modal-title custom_align" id="Heading">Gestió Imatges</h3>
</div>
<div class="modal-body">
<div class="">
<?php
// Load Images
$query = "SELECT t1.num, t1.imagen
FROM imatges AS t1
WHERE t1.codigo = '{$_GET['cod']}'
ORDER BY t1.num";
$result = dbQuery($conn, $query);
while ($row = pg_fetch_row($result)){
?>
<div class="box-image-library">
<img class="image-library" src='<?php echo $row[1];?>' id='fileImage'/>
<div class="btn-image-library-delete">
<button class='btn-image-library' id='deleteImage'><i class="material-icons" style="font-size: 20px">delete</i></button>
<button class='btn-image-library' id='downloadImage'><i class="material-icons" style="font-size: 20px">file_download</i></button>
</div>
<div class="box-text-image-library">
<span class="text-descripcio-image-library"><?php echo $row[1]; ?></span>
</div>
</div>
<?php
}
?>
</div>
</div>
<div class="modal-footer " >
<div class="pull-right">
<input type="submit" class="btn btn-gral btn-tool-footer-medium btn-icon" id='btnManageImagesAdd' value="Afegir">
<input type="submit" class="btn btn-gral btn-tool-footer-medium btn-icon" id='btnManageImagesSelect' value="Seleccionar">
<input type="submit" class="btn btn-gral btn-tool-footer-medium btn-icon" id='btnManageImagesFinalitzar' style="background-color: #73CBB0; color:black;" value="Finalitzar">
</div>
</div>
</div>
</div>
</div>
I would appreciate any help in this regard.
Thank you very much!