Created
July 26, 2017 02:12
-
-
Save anonymous/5b8e73ad676ba2300bc50b665a9425a2 to your computer and use it in GitHub Desktop.
Form Event Bubbling
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
{ | |
"version": "1.0.0", | |
"summary": "An efficient approach for handling changes with many controls on a page.", | |
"repository": "https://github.com/user/project.git", | |
"license": "BSD3", | |
"source-directories": [ | |
"." | |
], | |
"exposed-modules": [], | |
"dependencies": { | |
"elm-lang/core": "5.1.1 <= v < 5.1.1", | |
"elm-lang/html": "2.0.0 <= v < 2.0.0" | |
}, | |
"elm-version": "0.18.0 <= v < 0.19.0" | |
} |
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
<html> | |
<head> | |
<style> | |
html { | |
background: #F7F7F7; | |
color: red; | |
} | |
</style> | |
</head> | |
<body> | |
<script> | |
var app = Elm.Main.fullscreen() | |
</script> | |
</body> | |
</html> |
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
module Main exposing (..) | |
import Html exposing (Html, beginnerProgram, div, form, textarea) | |
import Html.Attributes exposing (name) | |
import Html.Events exposing (on) | |
import Json.Decode as Json | |
import Dict exposing (Dict) | |
type alias Model = | |
{ fields : Dict String String | |
} | |
type Msg | |
= Field String String | |
onInput tagger = | |
on "input" <| | |
Json.at [ "target" ] <| | |
Json.map2 tagger | |
(Json.field "name" Json.string) | |
(Json.field "value" Json.string) | |
model = | |
Model Dict.empty | |
update msg model = | |
case msg of | |
Field key value -> | |
{ model | fields = Dict.insert key value model.fields } | |
view model = | |
div [] | |
[ form [ onInput Field ] | |
[ textarea [ name "a01b" ] [] | |
, textarea [ name "b1c0" ] [] | |
] | |
] | |
main = | |
beginnerProgram { model = model, update = update, view = view } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment