Created
January 23, 2016 15:19
-
-
Save danyx23/27be1e9a9b387d9a7532 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Html exposing (div, button, text) | |
import Html.Events exposing (onClick) | |
import Signal exposing (Mailbox, mailbox, send) | |
import StartApp.Simple as StartApp | |
main = | |
StartApp.start { model = model, view = view, update = update } | |
model = "hi" | |
port getURL : Signal (String) | |
view address model = | |
div [] | |
[ div [] [ text model ] | |
, button [ onClick address SetURL ] [ text "SET" ] | |
] | |
type Action = SetURL | ResetURL | |
update action model = | |
case action of | |
SetURL -> "Set URL" | |
ResetURL -> "Reset" | |
{- | |
In Javascript: | |
$(document).ready(function(){ | |
$("#search-form").submit(function(event){ | |
elm.ports.getURL.send(this.baseURI); | |
event.preventDefault(); | |
}); | |
var div = document.getElementById('testelm'); | |
// embed our Elm program in that <div> | |
let elm = Elm.embed(Elm.Test, div, { | |
getURL: 'URL not set' | |
}); | |
}); | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment