Table of Contents
When developing Ajax-powered applications it is important to keep users informed when background actions are occurring. If they don't know that something is happening when they expect something to be happening they might grow impatient or give up.
To keep users informed, Recite provides a mechanism for displaying status messages. There are two types of status messages that can be displayed:
Loading messages. These are displayed when a background action is occurring. This includes processing a form, loading data, or any other action is occurring that the user may need to wait upon.
Status updates. These are displayed after some action has occurred. For instance, if you upload a file with the File Import widget a "File uploaded" message is displayed to the user so they know the action has completed.
Many status messages are triggered automatically from responses to Ajax requests. For more information on how send status messages from Ajax requests refer to the Ajax Requests chapter.
To display a loading message, use the following code:
Recite.Delegate.trigger('loadstart.status');
This will display a status message that says Loading...
.
You can display a custom message by passing an object with a string called
msg
as the second argument to trigger()
.
For example, to display the message Doing something...
, you
would use the following code:
Recite.Delegate.trigger('loadstart.status', { msg : 'Doing something...' });
By default the status message will be attached to the main browser window. If you
want to attach it to a different element you can pass the parent DOM element in the
parent
element of the second argument.