From 6864faee03c2fb608f09886f90c1bcf89cc7d6a1 Mon Sep 17 00:00:00 2001 From: nilsding Date: Sun, 28 Dec 2014 19:56:37 +0100 Subject: [PATCH] reporting answers works now --- app/assets/javascripts/answerbox/report.coffee | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/assets/javascripts/answerbox/report.coffee diff --git a/app/assets/javascripts/answerbox/report.coffee b/app/assets/javascripts/answerbox/report.coffee new file mode 100644 index 00000000..bacf29c1 --- /dev/null +++ b/app/assets/javascripts/answerbox/report.coffee @@ -0,0 +1,18 @@ +$(document).on "click", "a[data-action=ab-report]", (ev) -> + ev.preventDefault() + if confirm 'Are you sure you want to report this answer?' + btn = $(this) + aid = btn[0].dataset.aId + $.ajax + url: '/ajax/report' # TODO: find a way to use rake routes instead of hardcoding them here + type: 'POST' + data: + id: aid + type: 'answer' + success: (data, status, jqxhr) -> + showNotification data.message, data.success + error: (jqxhr, status, error) -> + console.log jqxhr, status, error + showNotification "An error occurred, a developer should check the console for details", false + complete: (jqxhr, status) -> + btn.button "reset" \ No newline at end of file