Why is it so important that your links does not start with a `#` aka fragment part?
Regards, Witold Szczerba On Sun, Dec 11, 2016 at 4:51 PM, Charlie Koster <[email protected]> wrote: > I think I came up with a workable solution by adding a tiny bit of > abstraction. > > import Html exposing (Attribute, Html, a) > import Html.Events exposing (onWithOptions, defaultOptions) > import Model exposing (Msg(..)) > import Json.Decode as Json > > > link : String -> List (Attribute Msg) -> List (Html Msg) -> Html Msg > link route attributes children = > let > clickHandler = > onWithOptions "click" defaultOptions <| Json.succeed <| > NavigateTo route > > attrs = > clickHandler :: attributes > in > a > attrs > children > > What this allows me to do is replace these: > > a [ onClick (NavMsg1 param1), class "some class", title "Do something" ] [ > text "Do something" ] > a [ onClick (NavMsg2), title "Do something else" ] [ text "Dom something > else" ] > a [ onClick (NavMsg3 param2 param3), class "is-disabled", title "Delete > thing" ] [ text "Delete thing" ] > > ..which has a lot of custom Msgs (one Msg per route).. and replace it with > > link ("/something?param1=" ++ param1) [ class "some class", title "Do > something" ] [ text "Do something" ] > link ("/home") [ title "Do something else" ] [ text "Dom something else" ] > link ("/deletePage?param2=" ++ param2 ++ "¶m3=" ++ param3) [ class > "is-disabled", title "Delete thing" ] [ text "Delete thing" ] > > The above reads very similar to using an anchor tag with an href attribute > which is what I was hoping for. > > Additionally, just as with your solution, there is only one Msg for going > to the different pages rather than a unique Msg for every different page. > > -- > You received this message because you are subscribed to the Google Groups > "Elm Discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
