2014-12-27 05:59:48 -08:00
|
|
|
$(document).on "click", "a[data-action=ab-destroy]", (ev) ->
|
|
|
|
ev.preventDefault()
|
2015-01-03 10:49:47 -08:00
|
|
|
btn = $(this)
|
|
|
|
aid = btn[0].dataset.aId
|
2015-01-03 08:36:55 -08:00
|
|
|
swal
|
2015-06-08 11:35:16 -07:00
|
|
|
title: translate('frontend.destroy_question.confirm.title')
|
|
|
|
text: translate('frontend.destroy_question.confirm.text')
|
2015-01-03 08:36:55 -08:00
|
|
|
type: "warning"
|
|
|
|
showCancelButton: true
|
|
|
|
confirmButtonColor: "#DD6B55"
|
2015-06-08 12:01:37 -07:00
|
|
|
confirmButtonText: translate('views.actions.y')
|
|
|
|
cancelButtonText: translate('views.actions.n')
|
2015-01-03 10:49:47 -08:00
|
|
|
closeOnConfirm: true
|
2015-01-03 08:36:55 -08:00
|
|
|
, ->
|
2014-12-08 06:45:15 -08:00
|
|
|
$.ajax
|
|
|
|
url: '/ajax/destroy_answer' # TODO: find a way to use rake routes instead of hardcoding them here
|
|
|
|
type: 'POST'
|
|
|
|
data:
|
|
|
|
answer: aid
|
|
|
|
success: (data, status, jqxhr) ->
|
|
|
|
if data.success
|
2014-12-13 06:40:31 -08:00
|
|
|
$("div.answerbox[data-id=#{aid}]").slideUp()
|
2014-12-08 06:45:15 -08:00
|
|
|
showNotification data.message, data.success
|
|
|
|
error: (jqxhr, status, error) ->
|
|
|
|
console.log jqxhr, status, error
|
2015-06-08 11:35:16 -07:00
|
|
|
showNotification translate('frontend.error.message'), false
|
2015-04-23 15:52:52 -07:00
|
|
|
complete: (jqxhr, status) ->
|