Form inputs are not present when .knack-view-render fires?

I’m trying to interact with form inputs inside a search view using $(document).on(‘knack-view-render.view_x’, function(event, view, data) {});

Each input in the form is (i.e. field on the object) is a connection. So when the view is rendered, I make an AJAX call to the connected object (more strictly to a view containing the connected object) to get back more information about each “option”, specifically an image to be added for illustrative purpose.

The AJAX call runs smoothly, and I easily get the required images back, however, when when I query the DOM to find each input (based on the “value” - which is the connected record’s ID) so that I can insert the image, the inputs are not present/available yet!

As far as I can tell, when “knack-view-render.view_x” fires, the view (or form within the view) has not actually finished rendering yet, making it impossible to find the elements I’m looking for!!

Is this true, and if so, what can I do? Is there an event that fires later, when the form has indeed completed loading / rendering?

Otherwise, what (assumedly idiotic) mistake am I making?


@David4 you could try the scene-render event as it fires after all the views have rendered, but I suspect this might not be long enough either. So next might be to try a timer of say half a second or long enough for the inputs to be present in the field.

Or someone smarter than me including ChatGPT might know how to use a MutationObserver event to fire when the field elements have loaded…

Hi Brad. Thanks for the reply. I ended up approaching this in a completely different manner.