Created
September 14, 2015 01:52
-
-
Save seanhess/4907042d91bc66bcb8ad to your computer and use it in GitHub Desktop.
Form.elm
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
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) | |
] [] | |
] |
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
@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?