getGalleryLink()) : ?>
registerJs('
$(function() {
$(document).on(\'click\', \'.gallery-file-remove\', function() {
var th = $(this);
console.log(th);
$.ajax({
method: \'post\',
url: th.data(\'url\'),
data : {
key: th.data(\'key\'),
' . Yii::$app->getRequest()->csrfParam . ': \'' . Yii::$app->getRequest()->getCsrfToken() . '\',
},
success: function(data) {
if (data.error == \'file deleted\') {
removeRow(th.closest(\'tr\'));
}
}
});
function removeRow(tr)
{
tr.remove();
if ($(\'#galleryTable tr\').length === 0) {
$(\'#galleryTable\').remove();
}
}
})
})
');