Implement AJAX deletion in /pages in order to remove redirect in /delete route.

This commit is contained in:
Bart Kamphorst
2018-10-19 21:04:31 +02:00
parent 825f43c429
commit 1a8b6d6823
3 changed files with 17 additions and 2 deletions
@@ -58,6 +58,22 @@ $(document).ready(function() {
e.preventDefault();
} );
$('.delete-file').click( function(e) {
var ok = confirm($(this).data('confirm'));
if ( ok ) {
var element = $(this);
$.post('<%=delete_path %>' + $(this).data('file-path'),
{},
function (result) {
// page successfully deleted, stay on page but remove element from DOM
element.closest("li").remove();
});
}
// Don't navigate on cancel.
e.preventDefault();
} );
var nodeSelector = {
node1: null,
node2: null,