How can I set the selected item in a select after adding a record?

I have a select (dynamic) with a button to add items to it. Clicking the button opens a modal which allows a record to be added. I then have an on success action to close the modal and reload the data so the select shows the new record. I have also added an action to Set Selected Index to the identity returned by the API but it’s not working.

Again, I suspect I’m doing it wrong. Initially I tried Set Value but that didn’t work either.

Here’s my code:

<form is="dmx-serverconnect-form" id="serverconnectformAddEngineer" method="post" action="dmxConnect/api/Jobs/AddEngineer.php" dmx-generator="bootstrap5" dmx-form-type="horizontal" dmx-on:success="modalAddEngineer.hide();connDropdownEngineers.load({});modalAddEditJob.serverconnectformAddEditJob.inp_jobEngineerID.setSelectedIndex(modalAddEngineer.serverconnectformAddEngineer.data.insertEngineer.identity)">

The API is returning the identity correctly (confirmed in the dev console).

Community Page
Last updated: