       type: "POST"
       dataType: "JSON"
       url: "/admin/messages/#{@getIds()}/spam"
-      success: (data) =>
-        $.each data, (i, message_id) => @removeMessage(message_id)
-    )
+      success: @removeMessages
+    ).always(@notify)
 
   ham: (event) =>
     @stopEvent(event)

    @hamBtn.addClass('disabled').removeClass('btn-warning')
    @deleteBtn.addClass('disabled').removeClass('btn-danger')

  stopEvent: (event) ->
    event.stopPropagation()
    event.preventDefault()

  getChecked: () => @element.find("input:checkbox:checked[data-checkbox='child']")
  getId:      (c) => $(c).data('id')
  getIds:     () => $.map(@getChecked(), (c) => @getId(c))

$.fn.actsAsMessagesTable = () ->
  @each ->
    new MessagesTable($(this))

jQuery ->
  $("table.messages.js-checkboxable").each ->

      type: "POST"
      dataType: "JSON"
      url: "/admin/messages/#{@getIds()}/ham"
      success: @removeMessages
    ).always(@notify)

  removeMessages: () =>
    $.each @getIds(), (i, message_id) => @removeMessage(message_id)

  removeMessage: (message_id) ->
    $("tr#message_#{message_id}").remove();
