Highlight Details View Label Body & Table Value
How to highlight a details view label body to bring attention to a field


The JS
The CSS
How to Implement
Last updated
Was this helpful?
How to highlight a details view label body to bring attention to a field


Last updated
Was this helpful?
Was this helpful?
//Change Label Body Background Color
function changeFieldColor(field, color_map) {
var child_field = $(field).find(".kn-detail-body");
var value = child_field.text();
if (color_map[value]) {
$(child_field).css({
"background-color": color_map[value].background_color,
color: color_map[value].color
});
}
}//Change Table Value Background Color
function changeTableFieldColor(field, color_map) {
var fields = $(field);
fields.each(function() {
var value = this.innerText;
if (color_map[value]) {
$(this).css({
"background-color": color_map[value].background_color,
color: color_map[value].color
});
}
});
}//Color Map Status Highlight
var colorMapOne = {
"Available": { background_color: "#80d07e", color: "#fff" },
"Unavailable": { background_color: "#ff9b9c", color: "#fff" }
};//Highlighted Field
$(document).on("knack-scene-render.any", function() {
changeFieldColor(".field_236", colorMapOne);
}); "Available": { background_color: "#80d07e", color: "#fff" },
"Unavailable": { background_color: "#ff9b9c", color: "#fff" } changeFieldColor(".field_236", colorMapOne);