$(function () { var errorDiv = $('
').addClass('error-message'); function error(msg) { $('.title').after(errorDiv.text(msg)); } $('.actions .certificate-delete').click(function () { $(this).parents('.actions').hide().parents('li').first().find('.revoke-q').show(); }); $('.revoke-q .no').click(function () { $(this).parents('.revoke-q').hide().parents('li').first().find('.actions').show(); }); $('.revoke-q .yes').click(function () { var _this=this; $.post('/panel/certificates/revoke', { name: $(_this).data('name') }, function (data) { if (data.success) { $(_this) .parents('li') .first() .remove(); } else { error(data.error); } }); }); });