Set Focus JS doesn't work in Millau 11.2 sandbox

edited February 4, 2020 in Questions
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);
    $('.nx-field > input').first().focus();
    $('.nx-field > input').first().select();
}, 100 );


  • Mark DeSimoneMark DeSimone 🛠️ 
    edited February 4, 2020
    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.
  • edited February 4, 2020

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

    $('.nx-field > input').first().focus();
    $('.nx-field > input').first().select();

     $('.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!
  • Mark DeSimoneMark DeSimone 🛠️ 
    edited August 27, 2018
    Glad to hear this! And thank you for closing the loop on this conversation. 
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!