Skip to content

Instantly share code, notes, and snippets.

@danyx23
Created January 23, 2016 15:19
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 danyx23/27be1e9a9b387d9a7532 to your computer and use it in GitHub Desktop.
Save danyx23/27be1e9a9b387d9a7532 to your computer and use it in GitHub Desktop.
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