How to modify the hover tooltip for choice column? Different description for each Choice
I am trying to use javascript or JSON to modify the hover tooltip so rather than displaying the name of the choice, I want it to display a description of that choice. I cannot get this script to work, but I am thinking maybe I am placing it in the wrong place.
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
$('span[title="Occupational injury"]').tooltip({
content: "Unexpected and unplanned occurrence, including acts of violence, arising out of or in connection with work which results in one or more workers incurring a personal injury, disease, or death."
});
$('span[title="Occupational illness"]').tooltip({
content: "An event or exposure that occurs in the workplace that causes or contributes to the worsening of a pre-existing condition."
});
$('span[title="Non-work-related injury/illness"]').tooltip({
content: "An injury or illness that occurs as a result of a non-work-related event or exposure."
});
$('span[title="Near-miss"]').tooltip({
content: "An event or condition that, under slightly different circumstances, could lead to an occupational injury or illness, an environmental incident, or property damage."
});
$('span[title="Environmental incident"]').tooltip({
content: "An event that may cause harm or potential harm to the environment (e.g., air, water, land, wildlife or local habitat)."
});
})
</script>
-
Hi Maria Giugno,
technically those are buttons and you can get them via a property called aria-label and then simply set it's title as below:
$('button[aria-label="Occupational injury"]').prop('title', 'Unexpected and unplanned occurrence, including acts of violence, arising out of or in connection with work which results in one or more workers incurring a personal injury, disease, or death.');
Kind regards
Matthias
0 -
Matthias_Walter Whenever you have a moment, can you provide me with a little more details of how to apply this? I am struggling to get it to work.
0 -
Hi Maria
It's hard to trigger this at the right time for manipulation because the option values are not loaded on form load - the values are loaded dynamically when you click on the dropdown... Since there is no event for selecting/opening dropdown I would suggest you could probably use for your case a separate list with two columns "Title" and "Description" containing your values which you can show on the form as enhanced lookup with additional columns to show in the dropdown.
Table "Incident Types"
Title Description
Occupational injury Unexpected and unplanned occurrence, including acts of violence, arising out of...
Occupational illness An event or exposure that occurs in the workplace that causes or contributes to th...
Non-work-related injury/illness An injury or illness that occurs as a result of a non-work-related event or expo...
Near-miss An event or condition that, under slightly different circumstances, could lead to an oc...
Environmental incident An event that may cause harm or potential harm to the environment (e.g., air, w...1 -
Christof I appreciate your detailed response! I am going to try this today.
0
Please sign in to leave a comment.
Comments
4 comments