Loading indicator
Loading Indicator Options
ReqEase provides a flexible Loading Indicator to give your users visual feedback about ongoing processes. These options are configured within the loading
property in the requester
options of ReqEase. Here's an overview:
loadingInModal
(boolean): This option controls whether or not to display the loading indicator in a modal dialog. When set totrue
, a modal with a loading spinner will be shown during the loading process.modalOptions
(object, optional): IfloadingInModal
is enabled, you can specify additional options for the modal, such as its title, content, and other settings. We'll discuss modal options in more detail in Modals.loadingIndicatorActions
(object): This object contains actions related to the Loading Indicator, allowing you to customize its behavior. One of its key methods isaffectButton
.spinnerIcon
(string, optional): You can set a custom spinner icon by providing the class or HTML content for the spinner. This will be displayed when the Loading Indicator is active.
affectButton
Function
affectButton
FunctionThe affectButton
function is responsible for managing the state of the "OK" button (or any other button specified in your ReqEase configuration) during loading. It takes three parameters:
loadingIndicator
(LoadingIndicator): The instance of the Loading Indicator.loadingIndicatorActions
(LoadingIndicatorActions): The Loading Indicator Actions object.toState
(LoadingState): The desired state of the button, which can be one of the following:LoadingState.NOT_LOADING
,LoadingState.LOADING
.
By default, the affectButton
function disables the button and adds a spinner icon to it when the Loading Indicator is active. It restores the original content of the button when the loading process is complete. This behavior ensures that users cannot interact with the form while a request is in progress, providing a smoother user experience.
Example of customizing affectButton
affectButton
In this example, we've overridden the affectButton
function to change the button's behavior based on the toState
parameter, which represents the loading state.
When
LoadingState.NOT_LOADING
is reached, we enable the button and restore its original content ("Submit").When
LoadingState.LOADING
is reached, we disable the button and display a custom loading message ("Loading...").
These Loading Indicator options give you fine-grained control over how loading is presented and how it interacts with your interface. You can customize it to suit the needs and style of your web application.
Last updated