Created
May 15, 2016 09:38
-
-
Save gdotdesign/44470da22f4701d36cb5187fff6d7c93 to your computer and use it in GitHub Desktop.
Event listener not removed
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.Events exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.App as App | |
import String | |
type alias Model = | |
{ haveTabindex : Bool | |
, text : String | |
} | |
init : Model | |
init = | |
{ haveTabindex = True | |
, text = "" | |
} | |
type Msg | |
= Change | |
| SetText | |
update : Msg -> Model -> Model | |
update msg model = | |
case msg of | |
SetText -> | |
{ model | text = "Hello There" } | |
Change -> | |
{ model | haveTabindex = False } | |
view : Model -> Html Msg | |
view model = | |
div | |
[] | |
[ div | |
(if model.haveTabindex then | |
[ onClick SetText, tabindex 0 ] | |
else | |
[] | |
) | |
[ text "Tab Me" ] | |
, button [ onClick Change ] [ text "setValue" ] | |
, text model.text | |
] | |
main : Program Never | |
main = | |
App.beginnerProgram | |
{ model = init | |
, update = update | |
, view = view | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment