Created
March 28, 2023 14:30
-
-
Save jon-dixon/87bdcd0713a1fc65af7642f81bb2e6b8 to your computer and use it in GitHub Desktop.
APEX Dynamic Inline Help Utility Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @namespace var cnUtil = {}; | |
**/ | |
var cnUtil = {}; | |
/** | |
* @function setInlineHelp | |
* @example cnUtil.setInlineHelp('P3_JUSTIFICATION', 'Hello World'); | |
**/ | |
cnUtil.setInlineHelp = function (itemID, inLineHelpText) { | |
// Build the JQuery selector used to find the In-Line help element. | |
let itemInlineHelpSelector = '#' + itemID + '_inline_help'; | |
// Debug Messages | |
apex.debug.info( "itemID: " + itemID); | |
apex.debug.info( "inLineHelpText: " + inLineHelpText); | |
// Check if the In-Line Help element already exists for the item. | |
if ($(itemInlineHelpSelector).length) { | |
// If In-Line help already exists, replace the Existing text. | |
$(itemInlineHelpSelector).text(inLineHelpText); | |
} else { | |
// If In-Line help does not exist. | |
// Build the JQuery selector to find the Page Item Container DIV. | |
let containerSelector = '#' + itemID + '_CONTAINER .t-Form-inputContainer'; | |
// Build a new DIV with the necessary HTML elements and In-Line help text. | |
let inlineHelpDiv = '<div class="t-Form-inlineHelp"><span id="' + itemID + | |
'_inline_help">' + inLineHelpText + '</span></div>'; | |
// Append the new DIV to the page item container DIV. | |
$(containerSelector).append(inlineHelpDiv); | |
} | |
}; | |
/** | |
* @function clearInlineHelp | |
* @example cnUtil.clearInlineHelp('P3_JUSTIFICATION'); | |
**/ | |
cnUtil.clearInlineHelp = function (itemID) { | |
let inlineHelpSelector = '#' + itemID + '_inline_help'; | |
apex.debug.info( "itemID: " + itemID); | |
apex.debug.info( "inlineHelpSelector: " + inlineHelpSelector); | |
$(inlineHelpSelector).remove(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment