Skip to content

Instantly share code, notes, and snippets.

@gdotdesign
Created May 15, 2016 09:38
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 gdotdesign/44470da22f4701d36cb5187fff6d7c93 to your computer and use it in GitHub Desktop.
Save gdotdesign/44470da22f4701d36cb5187fff6d7c93 to your computer and use it in GitHub Desktop.
Event listener not removed
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