Set Focus JS doesn't work in Millau 11.2 sandbox

The below In-Line snippet works in Skuid version 9 but not in version 10 or 11. This is a “set focus” snippet that we use when using a scanner so the user doesn’t have to manually put the cursor in the field. Does anyone know how to fix this?

var field = arguments[0];
$ = skuid.$; var delay = ( function() {
    var timer = 0;
    return function(callback, ms) {
        clearTimeout (timer);
        timer = setTimeout(callback, ms);
    };
})(); delay(function(){
    $('.nx-field > input').first().focus();
    $('.nx-field > input').first().select();
}, 100 );

Hi Tami, my guess is that these lines may need to be updated to account for changes to the HTML structure or CSS classes between the two Skuid releases you’re working with. 
$(’.nx-field > input’).first().focus();
$(’.nx-field > input’).first().select();

Also, if this is meant to run right on page load, I would make sure you wait until after the page is rendered before running this, because otherwise the above page elements may not yet exist when the script is running. Any easy way to try this chagne would be to trigger the snippet using an event-triggered action sequence, where the triggering event is the Skuid: page rendered event. Here’s some info on that approach.

Mark,

Thanks for your response. Making the following updates fixed the issue.

Updating:
$(’.nx-field > input’).first().focus();
$(’.nx-field > input’).first().select();

To:
 $(’.nx-field input, .nx-field textarea, .nx-field .flex-text-wrap pre, .nx-field .nx-richtext-input’).first().focus();
 $(’.nx-field input, .nx-field textarea, .nx-field .flex-text-wrap pre, .nx-field .nx-richtext-input’).first().select();


FYI: The snippet is not meant to be called on page load, it is called from within another snippet.

Thanks for your help!

Glad to hear this! And thank you for closing the loop on this conversation.