HELP!

message

This method displays a popup message dialog on the screen. The popup has a title, body and an OK button for the user to click to continue

xpertrule.message(content[, titleText[, buttonText[, options]]]);

All parameters except content are optional.

Function Parameters

Parameter Description
content This is a required string used to populate the contents of the popup message. The contents is automatically escaped so characters such as < are displayed as-is. If you require populating the popup with HTML, you sould set the html property on the options object
titleText An optional string used as the title of the popup. If no supplied, the text "Information" is used
buttonText An optional string used as the text for the "OK" button. If not supplied, the text "OK" is used
options An optional object containing additional popup settings. See section below for more details

The options Parameter (Object)

The optional options parameter is used to further enhance the functionality of the popup message. All properties are optional and detailed here...

Property Type Description
html Boolean If this property is set to true, the content supplied to the message function IS NOT escaped. This allows for custom HTML to be presented to the user in the popup message
showcancel Boolean If set to true, a Cancel button is included on the popup which (if clicked) hides the popup but does not continue inference
canceltext String If the cancel button is shown (via the showcancel property), this is the button's text (otherwise the text "Cancel" is used)
onshow Function This function is called once the popup has been populated and about to be displayed. The function receives a single parameter which is a jQuery object holding a reference to the contents of the popup body. See below for an example
oncanclose Function This function is called when the user clicks the OK button. The function receives a single parameter which is a jQuery object holding a reference to the contents of the popup body. If the function returns false then the popup is not exited, all other return values (including undefined) exit the popup as normal. See below for an example
oncancel Function If the cancel button is shown (via the showcancel property), this function is called just prior to the popup being hidden. The function receives a single parameter which is a jQuery object holding a reference to the contents of the popup body.

Examples

Simple Message

xpertrule.message("Hello World!");

Message with Custom Title and Button Text

xpertrule.message("Hello World!", "viabl Greetings", "Let's Go");

Message with a Checkbox that the user must click to Continue (shows the use of the options parameter)

let messageBody = `
You are about to proceed, check the Ts &amp; Cs<br>
<br>
<div class="ui checkbox">
  <input type="checkbox" id="message_accept_cb">
  <label>I accept these terms</label>
</div>
`;
xpertrule.message(
    messageBody,
    "Message Title",
    "OK",
    {
        html: true,
        showcancel: true,
        canceltext: "Nope",
        onshow: function($body) {
            let $input = $("#message_accept_cb");
            // make into sematic UI checkbox
            // https://semantic-ui.com/modules/checkbox.html
            $input.parent().checkbox(); 
        },
        canclose: function($body) {
            let $input = $("#message_accept_cb");
            if (!$input.is(":checked")) {
                $input.parent().find("label").css("color", "#f88"); // make input red
                return false; // returning false = do not exit the message popup
            }
        },
        oncancel: function() {
            replayStack.simpleBack();
        }
    }
);

On This Page