I have a delete link in Rails:
<%= link_to "#{image_tag("icons/icon_delete.png", :alt => "Delete")} Delete".html_safe, "#suppliers", id: supplier.id, class: "delete", :title => "Delete", :confirm => 'Are you sure?', :method => :delete %>
And I have a backbone event that catches it (CofeeScript):
events: ->
"click a.delete": "deleteSupplier"
deleteSupplier: (event) ->
event.preventDefault()
console.log("delete")
All of this works fine, except that when I click OK on the confirm dialog, the link is followed. Any ideas how to prevent this? If I return false from deleteSupplier the confirmation no longer works which isn't quite what I'm after. I'd like the confirmation to work, just not follow through the link when I click OK.
EDIT: I forgot to mention that these links are inserted after the page is loaded through an ajax get request. And I also tested by removing the :confirm and it doesn't seem to make any difference. I believe it has something to do with being loaded through the ajax request, but I would have thought that the event would not even fire if that were the case :(