-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onClick on link conflict with href #494
Comments
I still get that actually. |
Apparently the solution would be to use button for actions and links for navigation. I ended-up creating the following button class:
|
@Natim same happens to me since I'm using Elm 0.19, so I guess this behavior is more likely related to Elm 0.19 than to elm-css. I have ended up doing the same, using buttons rather than links :) |
I recently made the switch to using links correctly again. Trying to leverage the browser features. I ended up with the following solution: eventConfig : Bool -> Bool -> msg -> { message : msg, stopPropagation : Bool, preventDefault : Bool }
eventConfig stopPropagation preventDefault msg =
{ message = msg
, stopPropagation = stopPropagation
, preventDefault = preventDefault
}
onClickLink : msg -> Attribute msg
onClickLink msg =
custom "onclick" <| Json.map (eventConfig False True) (Json.succeed msg)
a [href "/demo", onClickLink GoToDemo] [] This solution prevents the link to work while still giving users the |
@littleStudent - can you confirm that you're using |
I suspect this is at the core of it: https://github.com/elm/virtual-dom/blob/master/src/Elm/Kernel/VirtualDom.js#L458-L461 Not sure how one would do anything that would impact the core Elm event handler. I've added a issue to elm/browser here which includes a work around of including a |
While using elm-css
href
andonClick
, I get both aUrlRequested Internal
and aonClick
events.I tried
With no luck so far. Any idea?
The text was updated successfully, but these errors were encountered: