I\'m having trouble using the event.preventDefault();
for an ahref
on my DOM.
How do you prevent the url from posting a nofollow delete, as spe
Are you using rails? Looks like it.
The reason event.preventDefault()
doesn't work is because the magic is done elsewhere.
Rails comes with some helpers that creates event handlers for all the "delete" actions generated by Rails. So in your case I think that you need to find out how to override the helpers or just create a custom event handler for that specific delete action.
This is the JQuery code that Rails uses:
https://github.com/rails/jquery-ujs/blob/master/src/rails.js
Based on this (from the link):
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]'
Your event handler will be the only one executed if you'd remove data-remote
, data-method
and data-confirm
from the link.
So I suggest that you remove them and then just re-create whatever behavior you want in your own click handler.