snap-extras-0.12.3.0: A collection of useful helpers and utilities for Snap web applications.

CopyrightSoostone Inc
LicenseBSD3
MaintainerOzgun Ataman
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Snap.Extras.Ajax

Description

Simple combinators to work with AJAX requests.

Synopsis

Documentation

replaceWith Source #

Arguments

:: MonadSnap m 
=> Text

jquery selector

-> ByteString

content blob

-> m () 

Replace innerHTML of given selector with given conntent.

replaceWithTemplate Source #

Arguments

:: 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.

Constructors

Html 
Ajax 

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

htmlOrAjax Source #

Arguments

:: 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.