You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
event.preventDefault() only prevents the link from being followed. event.stopImmediatePropagation() will stop the event from being propagated to other event handlers.
@fourcube I think I must have misunderstood your answer. When I use both preventDefault() and stopImmediatePropagation() together it works which is what I think you were referring to. So the solution is
Problem
Within a stimulus controller action,
event.preventDefault
is not stopping the ajax request created withremote: true
from alink_to
elementExpected
I would expect
event.preventDefault
to stop the ajax request as I believe it does withbutton_to
etc.Sample code
Output
The logs show the
new
route is accessed even thoughevent.preventDefault()
is called:Sample repo
https://github.com/MrHubble/stimuluslinkto
The text was updated successfully, but these errors were encountered: