Created
October 11, 2016 10:52
-
-
Save maxf/efd173cf14a77f4af381cf8ad4c13a20 to your computer and use it in GitHub Desktop.
Elm checkbox checked bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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