Copyright | Soostone Inc |
---|---|
License | BSD3 |
Maintainer | Ozgun Ataman |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Simple combinators to work with AJAX requests.
Synopsis
- replaceWith :: MonadSnap m => Text -> ByteString -> m ()
- replaceWithTemplate :: HasHeist b => ByteString -> Text -> Handler b v ()
- data ResponseType
- respond :: MonadSnap m => (ResponseType -> m b) -> m b
- responds :: MonadSnap m => [(ResponseType, m b)] -> m b
- htmlOrAjax :: MonadSnap m => m b -> m b -> m b
Documentation
:: MonadSnap m | |
=> Text | jquery selector |
-> ByteString | content blob |
-> m () |
Replace innerHTML of given selector with given conntent.
:: HasHeist b | |
=> ByteString | Heist template name |
-> Text | jQuery selector for target element on page |
-> Handler b v () |
Replace the inner HTML element of a given selector with the contents of the rendered Heist template.
Currently expect you to have jQuery loaded. TODO: Make this jQuery independent
data ResponseType Source #
Possible reponse types we support at the moment. Can be expanded for more use cases like JSON, CSV and XML.
Instances
Eq ResponseType Source # | |
Defined in Snap.Extras.Ajax (==) :: ResponseType -> ResponseType -> Bool # (/=) :: ResponseType -> ResponseType -> Bool # | |
Ord ResponseType Source # | |
Defined in Snap.Extras.Ajax compare :: ResponseType -> ResponseType -> Ordering # (<) :: ResponseType -> ResponseType -> Bool # (<=) :: ResponseType -> ResponseType -> Bool # (>) :: ResponseType -> ResponseType -> Bool # (>=) :: ResponseType -> ResponseType -> Bool # max :: ResponseType -> ResponseType -> ResponseType # min :: ResponseType -> ResponseType -> ResponseType # | |
Read ResponseType Source # | |
Defined in Snap.Extras.Ajax readsPrec :: Int -> ReadS ResponseType # readList :: ReadS [ResponseType] # | |
Show ResponseType Source # | |
Defined in Snap.Extras.Ajax showsPrec :: Int -> ResponseType -> ShowS # show :: ResponseType -> String # showList :: [ResponseType] -> ShowS # |
respond :: MonadSnap m => (ResponseType -> m b) -> m b Source #
The multi-mime dispatcher. It will inspect the Accept
header
and determine what type of a request this is. If AJAX, make sure to
set the Accept header to 'application/javascript'.
responds :: MonadSnap m => [(ResponseType, m b)] -> m b Source #
Dispatch on all response types
:: MonadSnap m | |
=> m b | If call is HTML |
-> m b | If call is AJAX |
-> m b |
Classic pattern of responding to a static HTML or an alternative AJAX request.