Quick actions

cmd+k|ctrl+k

Navigation

Languages

ContentEditable

Snippet info

Language

Elm

Visibility

public

Author

rohan.orton

Created

2016-04-26T16:22:04Z

Updated

2016-04-26T16:22:04Z

import StartApp.Simple exposing (start)
import Html exposing (Html, div, text)
import Html.Attributes exposing (contenteditable)
import Html.Events exposing (on, targetValue)


-- Model
type alias Model = String

init : Model
init = "Foo"

-- Update
type Action
  = Update String

update : Action -> Model -> Model
update action model =
  case action of
    Update content -> content


-- View
view : Signal.Address Action -> Model -> Html
view address model =
  div []
    [
      div [ contenteditable True
          , on "input" targetValue ((Signal.message address) << Update)
          ] [ text model ]
    , div [] [ text model ]
    ]


main =
  start
  { model = init
  , update = update
  , view = view
  }
INFO