I've used the mentioned "workaround" with Html.Keyed several times, and we
also use that approach on several pages at NoRedInk.

To summarize: the approach I'd personally use is the same that zwilias
suggests and shared an example of in the comments of the issue mentioned
previously:  https://ellie-app.com/3fPSxX6VHK7a1/0

view model =
   ...
   , Html.Keyed.node "div"
        [ ( toString model.generation ++ "-name"
          , Html.input [ Html.Attributes.defaultValue model.name ] []
          )
        ]
    , Html.button [ Html.Events.onClick Submit ] [ Html.text "Submit" ]
    ...

update msg model =
    case msg of
        ChangeName newName ->
            { model | name = newName }
        Submit ->
            { model | generation = model.generation + 1, name = "" }



On Wed, Jun 21, 2017 at 1:00 AM, zeh dude <mattia.d.de...@gmail.com> wrote:

> I struggled with this a bit some time ago (had to clear some form fields
> on command), and no matter which solution I tried there were unwanted side
> effects that I just could not make it work with just Elm.
>
> So what I ended up doing was use a port to use plain javascript to reset
> the field values and unlink the value of the fields from the model
> property.. it was the cleanest way I could find at the time and as soon as
> issue 105 is fixed I can remove it easily (I can just link back the model
> property to the value of the fields, and remove the command using the port).
> I wouldn't say this is the recommended way, but I just wanted to share the
> experience.
>
> --
> 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 elm-discuss+unsubscr...@googlegroups.com.
> 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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to