Font Size:
Ask Joget AI

UI

This page details the UI endpoints and the actions they support. It covers key functions, parameters, and sample code for easy implementation.

  • URL: /jw/js/json/ui.js
  • Auto-included in all userview pages.
  • Common utilities for UI, validation, and dialog interactions.

 

adjustPopUpDialog(dialogbox)

Used by the system to align the popup dialog to the center of the screen.

  • Parameters:
    • dialogbox - the popup dialog object
  • Sample code:
UI.adjustPopUpDialog(JPopup.dialogboxes["testPopup"]);

 

escapeHTML(content)

Used to escape HTML syntax in a value.

  • Parameters:
    • content - content to escape
  • Sample code:
var content = "<p>test content</p>";
var escapedContent = UI.escapeHTML(content);
console.log(escapedContent); // &lt;p&gt;test content&lt;/p&gt;

 

getPopUpHeight(height)

Used by the system to calculate the height of a popup dialog for the current screen size to support mobile devices.

  • Parameters:
    • height - The max height of the popup dialog. Default is "90%".
  • Sample code:
var height = UI.getPopUpHeight("500px");

 

getPopUpWidth(width)

Used by the system to calculate the width of a popup dialog for the current screen size to support mobile devices.

  • Parameters:
    • width - Max width of the popup dialog. Default is "90%".
  • Sample code:
var width = UI.getPopUpWidth("800px");

 

userviewThemeParams()

Returns the current userview's app and userview ID as query parameters (__a_ and __u_).

Sample code:

var url = "http://localhost/jw/form/embed?" + UI.userviewThemeParams();

 

 

stripHtmlTags(content)

Returns the text content of an HTML string without its markup.

  • Parameters: content - HTML content to extract text from
  • Sample code:
var text = UI.stripHtmlTags("<p>Hello</p>");
console.log(text); // Hello

 

stripHtmlRelaxed(content)

Removes script, style, iframe, and object elements and returns the remaining HTML markup.

  • Parameters: content - HTML content to process
  • Sample code:
var markup = UI.stripHtmlRelaxed("<p>Hello</p><script>run()</script>");
console.log(markup); // <p>Hello</p>

 

htmlDecode(string)

Decodes HTML entities in a string.

  • Parameters: string - string containing HTML entities
  • Sample code:
var text = UI.htmlDecode("&lt;p&gt;Hello&lt;/p&gt;");
console.log(text); // <p>Hello</p>

 

blockUI(options)

Blocks interaction with the page and displays a loading message. Optional settings can customize the jQuery BlockUI overlay.

  • Parameters: options - optional BlockUI settings; message overrides the default loading message
  • Sample code:
UI.blockUI({message: "Saving..."});
// Call UI.unblockUI() when the operation is complete.

 

unblockUI()

Removes the page-blocking overlay displayed by UI.blockUI.

UI.unblockUI();

 

validateEmail(emailSelector, multiple, callback)

Validates an email address by sending it to the Joget email-validation endpoint.

  • Parameters:
    • emailSelector - selector for the email input
    • multiple - value indicating whether multiple email addresses are allowed
    • callback - function called with true when valid or false when invalid
  • Sample code:
UI.validateEmail("#email", false, function(isValid) {
    console.log(isValid);
});

 

isValidInput(fieldLabel, input)

Checks whether input contains HTML tags or comments.

  • Parameters:
    • fieldLabel - label to include in the result when input is invalid
    • input - value to check
  • Returns: an object with valid: true, or valid: false, fieldLabel, and invalidTokens
  • Sample code:
var result = UI.isValidInput("Description", userInput);
if (!result.valid) {
    console.log(result.invalidTokens);
}

 

alert(text, args)

Displays an alert dialog.

  • Parameters: text - message to display; args - optional alert settings described for alertBlock
  • Sample code:
UI.alert("Saved successfully", {icon: "success"});

 

alertBlock(text, callback, args)

Displays an alert dialog and optionally calls a callback after it is dismissed.

  • Parameters:
    • text - message to display
    • callback - optional function called after the dialog is dismissed
    • args - optional settings: isHtml, icon, iconColor, title, buttonLabel, and buttonClass
  • Sample code:
UI.alertBlock("Saved successfully", null, {title: "Complete"});

 

confirm(text, confirmCallback, args)

Displays a confirmation dialog and invokes the appropriate callback based on the user's choice.

  • Parameters:
    • text - message to display
    • confirmCallback - optional function called when the user confirms
    • args - settings described for asyncConfirm; pass an object (which may be empty) and optionally include a cancelCallback
  • Sample code:
UI.confirm("Continue?", function() {
    console.log("Confirmed");
}, {});

 

asyncConfirm(text, options)

Displays a confirmation dialog and returns a promise that resolves to whether the user confirmed.

  • Parameters: text - message to display; options - optional settings: isHtml, icon, iconColor, title, confirmButtonLabel, cancelButtonLabel, confirmButtonClass, cancelButtonClass, and allowOutsideClick
  • Returns: a promise resolving to true if confirmed, or false otherwise
  • Sample code:
UI.asyncConfirm("Continue?").then(function(confirmed) {
    if (confirmed) {
        console.log("Confirmed");
    }
});

 

prompt(text, callback, options)

Displays a prompt dialog and calls the callback with the entered value when the user confirms.

  • Parameters:
    • text - message to display
    • callback - optional function called with the entered value
    • options - optional settings: isHtml, icon, iconColor, title, inputType, inputValue, inputPlaceholder, confirmButtonLabel, cancelButtonLabel, confirmButtonClass, and cancelButtonClass
  • Sample code:
UI.prompt("Enter your name", function(value) {
    console.log(value);
}, {inputPlaceholder: "Name"});
Created by Aadrian Last modified by Debanraj Ravindran on Nov 14, 2026