I have a simple form with one field. I would like to clear the field on the submit form. I clear my model in my update function, but the text remains in the text input.
type alias Model = { currentSpelling : String } type Msg = MorePlease update : Msg -> Model -> ( Model, Cmd Msg ) update msg model = case msg of MorePlease -> ( log "cleared spelling: " { model | currentSpelling = "" } , fetchWord model.currentSpelling ) view : Model -> Html Msg view model = div [] [ Html.form [ onSubmit MorePlease ] [ input [ type' "text" , placeholder "Search for your word here" , onInput NewSpelling , attribute "autofocus" "" ] [] , text model.currentSpelling , input [ type' "submit" ] [ text "submit!" ] ] ]
The text display showing model.currentSpelling is cleared when I clear it with the update function, but the text input field remains filled. Any idea how to clean it?
fetchWord makes an HTTP call, but it is omitted here.
source share