Skip to content

Instantly share code, notes, and snippets.

@leobm
Created July 16, 2013 15:42
Show Gist options
  • Save leobm/6009883 to your computer and use it in GitHub Desktop.
Save leobm/6009883 to your computer and use it in GitHub Desktop.
checkbox :: Bool -> IO (Elem, Signal Bool)
checkbox checked = do
c <- newElem "input"
(p,s) <- emptyPipe
setProp c "type" "checkbox"
sink (\isChecked -> do
setProp c "checked" $ if isChecked then "true" else ""
) s
setCallback c OnChange (do
checked <- getProp c "checked"
write p $ checked == "true"
)
write p checked
return (c,s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment