Show confirm dialog before deleting problem
This commit is contained in:
parent
a94df0dd49
commit
765f6e0ec1
2 changed files with 32 additions and 16 deletions
|
@ -56,23 +56,27 @@ var update_problem = function(form_id) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var delete_problem = function(form_id) {
|
var delete_problem = function(form_id) {
|
||||||
var input = "#" + form_id + " input";
|
$('#confirm').modal("show", { backdrop: 'static', keyboard: false })
|
||||||
var pid = form_id.split("_")[1];
|
.one('click', '#delete', function() {
|
||||||
$(input).attr("disabled", "disabled");
|
var input = "#" + form_id + " input";
|
||||||
api_call("POST", "/api/problem/delete", {"pid": pid}, function(result) {
|
var pid = form_id.split("_")[1];
|
||||||
if (result["success"] == 1) {
|
$(input).attr("disabled", "disabled");
|
||||||
display_message(pid + "_status", "success", result["message"], function() {
|
api_call("POST", "/api/problem/delete", {"pid": pid}, function(result) {
|
||||||
|
if (result["success"] == 1) {
|
||||||
|
display_message(pid + "_status", "success", result["message"], function() {
|
||||||
|
$(input).removeAttr("disabled");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
display_message(pid + "_status", "danger", result["message"], function() {
|
||||||
|
$(input).removeAttr("disabled");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, function(jqXHR, status, error) {
|
||||||
|
var result = jqXHR["responseText"];
|
||||||
|
display_message(pid + "_status", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
||||||
$(input).removeAttr("disabled");
|
$(input).removeAttr("disabled");
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
display_message(pid + "_status", "danger", result["message"], function() {
|
|
||||||
$(input).removeAttr("disabled");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, function(jqXHR, status, error) {
|
|
||||||
var result = jqXHR["responseText"];
|
|
||||||
display_message(pid + "_status", "danger", "Error " + jqXHR["status"] + ": " + result["message"], function() {
|
|
||||||
$(input).removeAttr("disabled");
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="confirm" class="modal fade">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-body">Are you sure you want to delete this problem?</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" data-dismiss="modal" class="btn btn-primary" id="delete">Delete</button>
|
||||||
|
<button type="button" data-dismiss="modal" class="btn">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$(".selectpicker").selectpicker();
|
$(".selectpicker").selectpicker();
|
||||||
|
|
Loading…
Reference in a new issue