diff --git a/src/main/resources/static/js/quiz/edit.js b/src/main/resources/static/js/quiz/edit.js index 3265730..45d75c8 100644 --- a/src/main/resources/static/js/quiz/edit.js +++ b/src/main/resources/static/js/quiz/edit.js @@ -13,6 +13,10 @@ $(document).ready(function () { $("#btn-edit-answer").click(function () { editAnswer(editor); }); + + $("#btn-delete-answer").click(function () { + deleteAnswer(); + }); }); function editAnswer(editor) { @@ -23,6 +27,7 @@ function editAnswer(editor) { alert("Input description"); return false; } + $.ajax({ url: '/answer', type: 'PUT', @@ -32,11 +37,33 @@ function editAnswer(editor) { 'description': description }), success: function () { - $("#answerResourceId").val('a'); alert("설명 추가 성공") + window.location = window.location }, error: function (e) { alert("설명 추가 실패"); } }); +} + +function deleteAnswer() { + const answerResourceId = $("#answerResourceId").val(); + + if (!answerResourceId) { + alert("Answer Not Exists"); + return false; + } + + $.ajax({ + url: '/answer/' + answerResourceId, + type: 'DELETE', + contentType: 'application/json', + success: function () { + alert("설명 삭제 성공"); + window.location = window.location + }, + error: function () { + alert("설명 삭제 실패"); + } + }); } \ No newline at end of file diff --git a/src/main/resources/templates/quiz/editQuiz.html b/src/main/resources/templates/quiz/editQuiz.html index 542fe28..a47274a 100644 --- a/src/main/resources/templates/quiz/editQuiz.html +++ b/src/main/resources/templates/quiz/editQuiz.html @@ -42,6 +42,7 @@
+