diff --git a/cps/editbooks.py b/cps/editbooks.py index cb8388ef..931ad13e 100644 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -229,14 +229,14 @@ def modify_identifiers(input_identifiers, db_identifiers, db_session): @editbook.route("/ajax/delete/") @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/", defaults={'book_format': ""}) @editbook.route("/delete//") @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): diff --git a/cps/static/js/main.js b/cps/static/js/main.js index 11ce6ed1..81308c64 100644 --- a/cps/static/js/main.js +++ b/cps/static/js/main.js @@ -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")); });