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
Is there any established convention for honoring [disabled] link elements?
When I click on a link that has the disabled attribute, Inertia navigates to it.
I've attempted these implementations: (my context is react)
Using document click eventListener
// This doesn't work... I believe because Inertia's navigation event precedes `document's` event?useEffect(()=>{document.addEventListener("click",ev=>{constisDisabledLink=ev.target.hasAttribute('disabled');if(isDisabledLink){ev.preventDefault();ev.stopPropagation();}});},[]);
I didn't get far with this method. When I console.logged the event param, I noticed that within it there was no way to access the actual link that invoked the event. In default browser DOM events, you can access the invoker via event.target but in these custom inertia events the target is the root document element.
One Extra note
In this issue I was trying to honor a link's disabled attribute. However it seems wise to make available the invoking element on these custom Inertia Events? People may want to "catch" the event and perform logic based on other attributes as well.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is there any established convention for honoring
[disabled]
link elements?When I click on a link that has the disabled attribute, Inertia navigates to it.
I've attempted these implementations: (my context is
react
)Using document
click
eventListenerUsing
Inertia.on(before), fn()
From https://inertiajs.com/events
I didn't get far with this method. When I console.logged the
event
param, I noticed that within it there was no way to access the actual link that invoked the event. In default browser DOM events, you can access the invoker viaevent.target
but in these custominertia
events thetarget
is the rootdocument
element.One Extra note
In this issue I was trying to honor a link's
disabled
attribute. However it seems wise to make available the invoking element on these custom Inertia Events? People may want to "catch" the event and perform logic based on other attributes as well.Beta Was this translation helpful? Give feedback.
All reactions