Created
March 11, 2016 08:36
-
-
Save pdamoc/004bbbfb76f695181f4a to your computer and use it in GitHub Desktop.
Insert 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
{ | |
"version": "1.0.0", | |
"summary": "helpful summary of your project, less than 80 characters", | |
"repository": "https://github.com/user/project.git", | |
"license": "BSD3", | |
"source-directories": [ | |
"." | |
], | |
"exposed-modules": [], | |
"dependencies": { | |
"elm-lang/core": "3.0.0 <= v < 4.0.0", | |
"evancz/elm-effects": "2.0.1 <= v < 3.0.0", | |
"evancz/elm-html": "4.0.2 <= v < 5.0.0", | |
"evancz/elm-http": "3.0.0 <= v < 4.0.0", | |
"evancz/start-app": "2.0.2 <= v < 3.0.0" | |
}, | |
"elm-version": "0.16.0 <= v < 0.17.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
module InsertHtml where | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (onClick) | |
outputMB : Signal.Mailbox String | |
outputMB = Signal.mailbox "" | |
port output : Signal String | |
port output = outputMB.signal | |
innerHtml : String | |
innerHtml = "<div>Thank you for clicking!</div>" | |
main : Html | |
main = | |
div [] | |
[ button [onClick outputMB.address innerHtml][ text "Click Me" ] | |
, br [] [] | |
, div [id "placeholder"] [] | |
] |
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> | |
<title>Inserting Html</title> | |
<script type="text/javascript" src="elm.js"></script> | |
</head> | |
<body style="margin: 0px;"> | |
</body> | |
<script type="text/javascript"> | |
var app = Elm.fullscreen(Elm.InsertHtml); | |
app.ports.output.subscribe(insertString); | |
function insertString(innerHtml) { | |
var placeholder = document.getElementById("placeholder"); | |
placeholder.innerHTML = innerHtml; | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment