Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

paf31/purescript-jquery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

purescript-jquery

Latest release Maintainer: paf31

PureScript type declarations for jQuery. See module documentation on Pursuit.

Example

main = ready do
  -- Get the document body
  body <- body

  -- Create a text box
  div   <- create "<div>"
  input <- create "<input>"
  appendText "Your Name: " div
  append input div
  append div body

  -- Create a paragraph to display a greeting
  greeting <- create "<p>"
  css { color: "red" } greeting
  append greeting body

  -- Listen for change events on the text box
  on "change" (handleChange input greeting) input

  where
  handleChange :: JQuery -> JQuery -> JQueryEvent -> JQuery -> Effect Unit
  handleChange input greeting _ _ = unsafePartial do
    val <- getValue input
    for_ (runExcept (readString val)) \name -> do
      log $ "Name changed to " <> name
      setText ("Hello, " <> name) greeting

(from test/Main.purs).

Installation

bower i purescript-jquery