Skip to content

Instantly share code, notes, and snippets.

@pdamoc
Created March 11, 2016 08:36
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 pdamoc/004bbbfb76f695181f4a to your computer and use it in GitHub Desktop.
Save pdamoc/004bbbfb76f695181f4a to your computer and use it in GitHub Desktop.
Insert Html
{
"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"
}
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"] []
]
<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