Stability | experimental |
---|---|
Maintainer | Ozgun Ataman |
Safe Haskell | None |
Simple combinators to work with AJAX requests.
- replaceWith :: MonadSnap m => Text -> ByteString -> m ()
- replaceWithTemplate :: HasHeist v => ByteString -> Text -> Handler v 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 v | |
=> ByteString | Heist template name |
-> Text | jQuery selector for target element on page |
-> Handler v 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.
respond :: MonadSnap m => (ResponseType -> m b) -> m bSource
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 bSource
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.