Skip to content
This repository has been archived by the owner. It is now read-only.

paf31/purescript-jquery

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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