Skip to content

Instantly share code, notes, and snippets.

@maxf
Created October 11, 2016 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxf/efd173cf14a77f4af381cf8ad4c13a20 to your computer and use it in GitHub Desktop.
Save maxf/efd173cf14a77f4af381cf8ad4c13a20 to your computer and use it in GitHub Desktop.
Elm checkbox checked bug
import Html exposing (..)
import Html.App as App
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
main =
App.beginnerProgram { model = model, view = view, update = update }
-- MODEL
type alias Model = List String
model : Model
model =
[ "one", "two", "three", "four" ]
-- UPDATE
type Msg = Kill String
update : Msg -> Model -> Model
update msg model =
case msg of
Kill name ->
List.filter (\s -> s /= name) model
-- VIEW
viewLi : String -> Html Msg
viewLi s =
li []
[ input [type' "checkbox", onClick (Kill s)] [], text s ]
view : Model -> Html Msg
view model =
ul [] (List.map viewLi model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment