Displaying Alerts, Errors, Confirmations - tsgrp/HPI GitHub Wiki
HPI 2.x Alert Module
The new Alert Module creates an easy way to display an alert modal to show error, info, confirmation, or custom alerts as well as optionally collect feedback.
- The Error Modal provides a supplied message and time stamp of the error.
- The Info Modal provides a supplied message.
- The Confirmation Modal provides a supplied message, takes labels, and has callbacks for Yes/No buttons.
- The Custom Modal takes a View which is passed into the modal and rendered.
The options hash supports the following keys:
- message - (string)the message to display
- header - (string)the header of the modal
- [confirm] - (function) the function to call when user clears the modal. (Called on OK for error/info, and YES on confirmation)
- [confirmLabel] - (String) Label for success function. Defaults to OK
- [cancel] - (function) the function to call when user clears a confirmation modal with a cancel action. Not applicable for error/info modals
- [cancelLabel] - (string) Label for cancel function. Defaults to Cancel
The new format of calling the Alert Module:
- app.trigger(“alert:error”, {message: “message”, header: “header”})
Example of a Confirmation Alert:
app.trigger("alert:confirmation", {
message : "message",
header : "header",
confirm: function() {
...........
}
});
An example of the custom alert:
app.trigger("alert:custom", {view : new ViewType({model: this.model})});