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
});
});