Class: Alert

Alert

new Alert(options)

Display a message.

Display one message on a page. Several instances can be used per page, which results in messages being stacked, with the latest message being at the bottom.

The first instance displaying a message will append an alert container to the body. The last message being dismissed will remove the alert container. A typical call sequence might look like:

var alert = new QfqNS.Alert({
    message: "Text being displayed",
    type: "info"
    });
    alert.show();

Messages may have different background colors (severity levels), controlled by the type property. Possible values are

  • "info"
  • "warning"
  • "error"

The values are translated into Bootstrap alert-* classes internally.

If no buttons are configured, a click anywhere on the alert will close it.

Buttons are configured by passing an array of objects in the buttons property. The properties of the object are as follows

{
    label: <button label>,
    focus: true | false,
    eventName: <eventname>
    }

You can connect to the button events by using

var alert = new QfqNS.Alert({
    message: "Text being displayed",
    type: "info",
    buttons: [
    { label: "OK", eventName: "ok" }
    ]
    });
    alert.on('alert.ok', function(...) { ... });

Events are named according to alert.<eventname>.

If the property modal is set to true, a kind-of modal alert will be displayed, preventing clicks anywhere but the alert.

For compatibility reasons, the old constructor signature is still supported but deprecated

var alert = new QfqNS.Alert(message, type, buttons)

Parameters:
Name Type Description
options object

option object having following properties

Properties
Name Type Attributes Description
message string

message to be displayed

type string <optional>

type of message, can be "info", "warning", or "error". Default is "info".

modal boolean <optional>

whether or not alert is modal, i.e. prevent clicks anywhere but the dialog. Default is false.

buttons Array.<object>

what buttons to display on alert. If empty array is provided, no buttons are displayed and a click anywhere in the alert will dismiss it.

Properties
Name Type Attributes Description
label string

label of the button

eventName string

name of the event when button is clicked.

focus boolean <optional>

whether or not button has focus by default. Default is false.

Source:

Methods

(private) afterFadeIn()

Source:

(private) buttonHandler(handler)

Parameters:
Name Type Description
handler
Source:

(private) countAlertsInAlertContainer() → {number|jQuery}

Source:
Returns:
Type
number | jQuery

(private) getAlertClassBasedOnMessageType()

Source:

(private) getButtons()

Source:

(private) makeAlertContainerSingleton()

Source:

(private) removeAlert()

Source:

(private) removeAlertContainer()

Source: