Skip to content

Instantly share code, notes, and snippets.

@gdotdesign
Created May 5, 2016 07:57
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/24926f96f1ad7f5b2af5a0189fe9111e to your computer and use it in GitHub Desktop.
Save gdotdesign/24926f96f1ad7f5b2af5a0189fe9111e to your computer and use it in GitHub Desktop.
Uncaught TypeError: Cannot read property 'index' of undefined
import Html.Attributes exposing (style)
import Html.Events exposing (onClick, onMouseDown)
import Html exposing (node, div, text)
import Html.App
import Html.Lazy
type alias Model =
{ color : String
, clicks : Int
}
type Msg
= Click
init : Model
init =
{ clicks = 0
, color = "black"
}
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
Click ->
( { model | clicks = model.clicks + 1, color = "red" }, Cmd.none )
view : Model -> Html.Html Msg
view model =
node
"div"
[ onClick Click
, onMouseDown Click
, style [("font-size", "30px")]
]
[ text (toString model.clicks)
, Html.Lazy.lazy2 div [] [text "asd"]
]
main =
Html.App.program
{ init = ( init, Cmd.none )
, view = Html.Lazy.lazy view
, update = update
, subscriptions = \model -> Sub.none
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment