Position cursor automatically on a form

I have a simple form where I want to position the cursor in a field "automatically" without a mouse click or tabs every time the form loads.

I've gotten the following code to work -- but only for a text field-types.  Unfortunately, the field I want to "select" is a Connection field-type.

Any ideas?

$(document).on('knack-scene-render.scene_23', function(event, scene) {
  // Do something after the scene renders
  // must be field with class=input; type=text
  $('#field_5').focus().select();
});

 

Norm:

I got your suggestion to work for me.

 

BTW, my use-case is very similar -- connected field ready for input from a barcode scanner.

 

One clarification -- what needs to change when Knack migrates to the new API?  Also, how will we know when they change?

 

Thanks.

 

-Jeff