make sure the user really wants to delete something…
This commit is contained in:
parent
c486c293ef
commit
2d8305095b
|
@ -1,18 +1,19 @@
|
|||
$(document).on "click", "button[name=ab-destroy]", ->
|
||||
btn = $(this)
|
||||
btn.button "loading"
|
||||
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
|
||||
$("div.answer-box[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
|
||||
complete: (jqxhr, status) ->
|
||||
btn.button "reset"
|
||||
if confirm 'Are you sure?'
|
||||
btn = $(this)
|
||||
btn.button "loading"
|
||||
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
|
||||
$("div.answer-box[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
|
||||
complete: (jqxhr, status) ->
|
||||
btn.button "reset"
|
|
@ -27,22 +27,23 @@ $(document).on "click", "button[name=ib-answer]", ->
|
|||
$("textarea[name=ib-answer][data-id=#{iid}]").removeAttr "readonly"
|
||||
|
||||
$(document).on "click", "button[name=ib-destroy]", ->
|
||||
btn = $(this)
|
||||
btn.button "loading"
|
||||
iid = btn[0].dataset.ibId
|
||||
$("textarea[name=ib-answer][data-id=#{iid}]").attr "readonly", "readonly"
|
||||
$.ajax
|
||||
url: '/ajax/delete_inbox'
|
||||
type: 'POST'
|
||||
data:
|
||||
id: iid
|
||||
success: (data, status, jqxhr) ->
|
||||
if data.success
|
||||
$("div.inbox-box[data-id=#{iid}]").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
|
||||
complete: (jqxhr, status) ->
|
||||
btn.button "reset"
|
||||
$("textarea[name=ib-answer][data-id=#{iid}]").removeAttr "readonly"
|
||||
if confirm 'Are you sure?'
|
||||
btn = $(this)
|
||||
btn.button "loading"
|
||||
iid = btn[0].dataset.ibId
|
||||
$("textarea[name=ib-answer][data-id=#{iid}]").attr "readonly", "readonly"
|
||||
$.ajax
|
||||
url: '/ajax/delete_inbox'
|
||||
type: 'POST'
|
||||
data:
|
||||
id: iid
|
||||
success: (data, status, jqxhr) ->
|
||||
if data.success
|
||||
$("div.inbox-box[data-id=#{iid}]").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
|
||||
complete: (jqxhr, status) ->
|
||||
btn.button "reset"
|
||||
$("textarea[name=ib-answer][data-id=#{iid}]").removeAttr "readonly"
|
Loading…
Reference in New Issue