-
Goal: when user clicks a row in a table, we want it to populate a field in a search form (that part is easy) and then highlight that input field's background with a different color, temporarily.
-
Steps:
- with a standard CONTROL COMPONENT click handler, it's easy to
setValue( {{currentRow.CODE}} ),
no problem - we have CSS set up like so:
.srch_fld {
background-color: #9999ff;
transition: background-color 1s ease;
}
- triggering the set-class javascript is where we have our main puzzle: how/where do we switch between retool-objects and javascript-dom-objects?
function srch_fld (which,val) {
console.log(which);
which.setValue(val);
const fld = document.querySelector("input[name='" + which.id + "']"); // nope
fld.classList.add("srch_fld");
setTimeout(() => { fld.classList.remove("srch_fld")},1200);
}
Presumably we would call this in a ROW-ACTION RUN-SCRIPT handler like so:
srch_fld( the_input_field_obj_here, currentRow.CODE )
But that gives us
// Error:Cannot read properties of null (reading 'classList')
We've also tried document.getElementById(which.id)
to the same result.
This is gonna be simple, but we haven't quite got the right combo. Ideas?
We are on Retool Cloud.