On my login page, I want to set the focus on the first field.
I added a helper to do so
can.stache.registerHelper('placeFocus',function(){
setTimeout(()=>{
$($('input')[0]).focus().css('background', 'yellow');
}, 10);
})
The jquery call that is the guts works correctly in the console. The timeout allows the DOM to complete before it runs. If I console.dir() the selected DOM object, it’s the correct one. When I set it to a stupidly long length of time (10000), it still does nothing.
What am I missing?