I have a very simple SPA, one textbox, two buttons, and a div for showing 
messages.

The aim of the app is to analyse the text in the textbox (on clicking the 
'Process' button) to show messages in the div.

The other button, Reset, is supposed to clear the textbox and the messages.

The 'update' and 'view' functions are very simple

type Msg = Reset | Process | Change String

update : Msg -> Model -> Model
update msg model =
  case msg of
    Reset -> {model | kontent = "", messages =[]}
    Process -> createMessages model
    Change newcontent -> {model | kontent = newcontent}

-- VIEW

view : Model -> Html Msg
view model =
   div []
    [ textarea [kontentStyle, onInput Change] [text (model.kontent)]
    , button [ onClick Reset ] [ text "Reset" ]
    , button [ onClick Process ] [ text "Process" ]
    , div [] (makeMessages (model.messages))
    ]


But what happens, on pressing the 'Clear' button, is that the model updates 
as expected ...

Reset -> {model | kontent = "", messages =[]}


and the messages in the div clear ... but the textbox doesn't clear. 
Furthermore, the Process button doesn't generate the messages it did 
before. It's as if the model is saying it has no content, but the textarea 
is still full of text. Yet the line:

textarea [kontentStyle, onInput Change] [text (model.kontent)]


.. should ensure that whatever is in the model, is also in the textbox.

Does anyone have an idea where I'm going wrong?

-- 
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