diff --git a/strongMan/apps/certificates/static/certificates/details.js b/strongMan/apps/certificates/static/certificates/details.js index 1de7778e..536c4778 100644 --- a/strongMan/apps/certificates/static/certificates/details.js +++ b/strongMan/apps/certificates/static/certificates/details.js @@ -1,15 +1,21 @@ -/** - * Created by root on 18/04/16. - */ +jQuery(function($) { + var $remove_btns = $('button.remove-btn'); + $remove_btns.each(function () { + var $btn = $(this); + var $form = $btn.closest('form'); -function removeBtnClicked(form) { - jform = $(form); - btn = jform.find('.remove-btn'); - if (btn.hasClass('btn-default')) { - btn.removeClass('btn-default').addClass('btn-danger'); - btn.find('.removebtn-text').text('Are you sure?'); - return false; - } else { - return true; - } -} + var $submitter = null; + $form.submit(function (form) { + if ($submitter && $submitter[0] == $btn[0] && $btn.hasClass('btn-default')) { + $btn.removeClass('btn-default').addClass('btn-danger'); + $btn.find('.removebtn-text').text('Are you sure?'); + return false; + } else { + return true; + } + }); + $form.find('button[type=submit]').click(function () { + $submitter = $(this); + }); + }); +}); diff --git a/strongMan/apps/certificates/templates/certificates/details.html b/strongMan/apps/certificates/templates/certificates/details.html index 4c0c1afa..718718e6 100644 --- a/strongMan/apps/certificates/templates/certificates/details.html +++ b/strongMan/apps/certificates/templates/certificates/details.html @@ -169,21 +169,23 @@