Skip to content

Instantly share code, notes, and snippets.

@cathylill
Last active November 8, 2017 00:22
Show Gist options
  • Save cathylill/6d480749784b9f54349d4eb043d7abbf to your computer and use it in GitHub Desktop.
Save cathylill/6d480749784b9f54349d4eb043d7abbf to your computer and use it in GitHub Desktop.
Get text input on click
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecursiveDo #-}
import Reflex.Dom
import qualified Data.Text as T
main :: IO ()
main = mainWidget $ do
el "h1" $ text "Reflex FRP Autocomplete Example - Canva Frontend Meetup"
el "h2" $ text "Part 2 - Adding updating a Dynamic on button click"
el "section" $ do
addItem
addItem :: MonadWidget t m => m ()
addItem = mdo
addItemText <- textInput $ def
& setValue .~ ("" <$ eAddItemClick)
eAddItemClick <- button "Add"
let evText = tag (current (value addItemText)) eAddItemClick
el "p" $ dynText =<< holdDyn "" evText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment