I have been trying to use Html.select (the drop-down menu). Unfortunately
the selected attribute doesn't seem to work for me.
Some context: I am attempting the exercises at the bottom
of https://guide.elm-lang.org/architecture/effects/http.html. As new
topics are entered in the input box, they should be added to the drop-down
menu. I found this would sporadically cause the menu selection to jump
around, so I tried to handle it manually using the selected attribute.
Anybody have any ideas how to do this so it works? The relevant piece of
code looks something like this:
view : Model -> Html Msg
view model =
div []
[ input [ onInput ChangeTopic ] []
, select [ onInput SelectTopic ]
(List.map
(makeOption model.selectedTopic)
(Set.toList model.allTopics)
)
, button [ onClick MorePlease ] [ text "Go!" ]
, img [ src model.gifUrl ] []
]
makeOption : String -> String -> Html msg
makeOption selectedTopic topic =
option
(if topic == selectedTopic then
[ value topic, selected True ]
else
[ value topic ]
)
[ text topic ]
--
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.