After Deleting a book the list page is still displayed #1938

This commit is contained in:
Ozzie Isaacs 2021-04-07 18:19:48 +02:00
parent fac232229e
commit 78071841cc
2 changed files with 5 additions and 3 deletions

View File

@ -229,14 +229,14 @@ def modify_identifiers(input_identifiers, db_identifiers, db_session):
@editbook.route("/ajax/delete/<int:book_id>")
@login_required
def delete_book_from_details(book_id):
return Response(delete_book(book_id,"", True), mimetype='application/json')
return Response(delete_book(book_id, "", True), mimetype='application/json')
@editbook.route("/delete/<int:book_id>", defaults={'book_format': ""})
@editbook.route("/delete/<int:book_id>/<string:book_format>")
@login_required
def delete_book_ajax(book_id, book_format):
return delete_book(book_id,book_format, False)
return delete_book(book_id, book_format, False)
def delete_whole_book(book_id, book):

View File

@ -142,10 +142,11 @@ $("#delete_confirm").click(function() {
//get data-id attribute of the clicked element
var deleteId = $(this).data("delete-id");
var bookFormat = $(this).data("delete-format");
var ajaxResponse = $(this).data("ajax");
if (bookFormat) {
window.location.href = getPath() + "/delete/" + deleteId + "/" + bookFormat;
} else {
if ($(this).data("delete-format")) {
if (ajaxResponse) {
path = getPath() + "/ajax/delete/" + deleteId;
$.ajax({
method:"get",
@ -187,6 +188,7 @@ $("#deleteModal").on("show.bs.modal", function(e) {
}
$(e.currentTarget).find("#delete_confirm").data("delete-id", bookId);
$(e.currentTarget).find("#delete_confirm").data("delete-format", bookfomat);
$(e.currentTarget).find("#delete_confirm").data("ajax", $(e.relatedTarget).data("ajax"));
});