目次

Version 2, last updated by Richard Dallaway at Jun 21 07:10 UTC

An AJAX spinner (a.k.a AJAX loader or throbber) is a visual indication you can show when an AJAX action is being performed.

You can enable this behaviour in Lift via the following lines in Boot:

LiftRules.ajaxStart = Full( () => LiftRules.jsArtifacts.show("ajax-spinner").cmd )
LiftRules.ajaxEnd = Full( () => LiftRules.jsArtifacts.hide("ajax-spinner").cmd )

In this instance Lift will show and hide the HTML element with an id of ajax-spinner. The corresponding HTML on the page might be:

<div style="display:none" id="ajax-spinner">
<img src="/images/spinner.gif" width="16" height="16"/>
</div>

You will need to supply a graphic (e.g., images/spinner.gif in this example) in your Lift application. One source of loader graphics is: http://www.ajaxload.info/

Note that LiftRules.ajaxStart and ajaxEnd support is much more general than just showing a spinner and can contain arbitrary JavaScript commands.