Is there an easy way to add stopPropagation to phx-click?
I have a button inside a list item where entire list item is an a tag, so naturally clicking button also triggers redirection with a.
This certainly can be done with hooks and that’s my current approach, but I was thinking if there’s some easier way to do it with phx-click or to slightly extend phx-click?
The phx-capture-click event is just like phx-click , but instead of the click event being dispatched to the closest phx-click element as it bubbles up through the DOM, the event is dispatched as it propagates from the top of the DOM tree down to the target element. This is useful when wanting to bind click events without receiving bubbled events from child UI elements. Since capturing happens before bubbling, this can also be important for preparing or preventing behaviour that will be applied during the bubbling phase.
Thanks, this is working fine! I’ve tried it before but it wasn’t working. Turns out there was just an error thrown by the handler and somehow link redirection kicked in anyway.
appreciate this is an old thread but noticed that capture-click is no longer documented in version 0.17.5 and seems to have been replaced with click-away. capture-click certainly still works in 0.17.5 but I wondered if any of the Liveview team could confirm that it isn’t going to be depracted?