-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle clicks to remove buttons more generically in certificate view
This allows placing more than one button in a form.
- Loading branch information
1 parent
81c135b
commit dbb037a
Showing
2 changed files
with
22 additions
and
16 deletions.
There are no files selected for viewing
34 changes: 20 additions & 14 deletions
34
strongMan/apps/certificates/static/certificates/details.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters