Retrospring/app/assets/javascripts/answerbox/destroy.coffee

26 lines
923 B
CoffeeScript
Raw Normal View History

2014-12-27 05:59:48 -08:00
$(document).on "click", "a[data-action=ab-destroy]", (ev) ->
ev.preventDefault()
2015-01-03 08:36:55 -08:00
swal
title: "Really delete?"
text: "The question will be moved back to your inbox."
2015-01-03 08:36:55 -08:00
type: "warning"
showCancelButton: true
confirmButtonColor: "#DD6B55"
confirmButtonText: "Delete"
2015-01-03 08:36:55 -08:00
closeOnConfirm: false
, ->
btn = $(this)
aid = btn[0].dataset.aId
$.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()
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
2014-12-28 10:56:13 -08:00
complete: (jqxhr, status) ->