Last active
February 5, 2016 01:56
-
-
Save paldepind/f8120090f42ba572c4d1 to your computer and use it in GitHub Desktop.
Helper function for creating forms in Reflex. The default of forms is prevented. A submit event and child is returned.
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
import GHCJS.DOM.EventM (event, preventDefault) | |
import GHCJS.DOM.Element | |
form :: MonadWidget t m => m a -> m (Event t (), a) | |
form child = do | |
(form, ch) <- el' "form" child | |
submit <- wrapDomEvent (_el_element form) elementOnsubmit (void $ preventDefault) | |
performEvent_ (return () <$ submit) | |
return (submit, ch) |
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
(submitAppend, appendText) <- form $ do | |
appendText <- textInput def | |
button "Append" | |
return appendText | |
appendText <- return $ tag (current (_textInput_value appendText)) submitAppend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment