Auto Reloading Form

The code below is used to set focus on a dropdown selection list when the view renders. It works when the page is orginally loaded, however when the form is submitted and ‘automatically reloaded’ it does not work. Any ideas on how to get it to work when the form is ‘automatically reloaded’ would be appreciated.

$(document).ready(function() {
$(document).on(‘knack-scene-render.scene_32’, function(event, scene) {
setTimeout(function() {
var $dropdownToggle = $(‘#view_104_field_154_chzn > a’);
var $searchInput = $(‘#view_104_field_154_chzn input[type=“text”]’);

     // Add the class to show the dropdown options
     $dropdownToggle.addClass('chzn-with-drop');

     // Trigger the mousedown event to open the dropdown
     $dropdownToggle.trigger('mousedown');

     // Set focus on the search input field
     $searchInput.focus();
  }, 100); // Adjust the delay (in milliseconds) as needed

});
});

Hey @Joseph2 would it work inside the view render event instead of the scene render?

i.e.

$(document).on('knack-view-render.view_104', function(event, view, data) {
    setTimeout(function() { .....

    });
});