Skip to content

Instantly share code, notes, and snippets.

@seanhess
Created September 14, 2015 01:52
Show Gist options
  • Save seanhess/4907042d91bc66bcb8ad to your computer and use it in GitHub Desktop.
Save seanhess/4907042d91bc66bcb8ad to your computer and use it in GitHub Desktop.
Form.elm
type Action
= Update String
| Enter
type alias Model = { text : String }
update : Action -> Model -> Model
update action model
case action of
Update txt -> { model | text <- txt }
Enter ->
-- probably want to enhance this to add effects
-- see elm architecture
-- return an effect to load your data
{ model | text <- "" }
view : Address Action -> Props -> State -> Html
view address props state =
form
[ action "javascript:none"
, onSubmit address Enter
]
[ input
[ type' "text"
, placeholder "search"
, value state.searchTerm
, on "input" targetValue (Signal.message address << Update)
] []
]
@amitaibu
Copy link

@seanhess it seems the action "javascript:none" trick works for a single input, but not for multiple. Were you able to use it on a more complex form?

@seanhess
Copy link
Author

For future reference, the proper thing to put in there is action "javascript:void(0)". I have no idea if it works for more than one input. I hope so :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment