Tuesday, April 19, 2016

Fancybox Modal Window onFocus or $('#ID').onFocus();

How to give focus to a modal window?

Be patient.  Add a timer.  That did it for me.

This was a 2 day R&D problem. After adding the timeout BAM --- Focus achieved.  This really was a tricking thing to figure out, but think about it if the HTML DOM ELEMENT is not there it cannot set focus.

$(document).ready(function setFocus() {
         setTimeout(function () {
             $('#txtEmailAddress').focus();
         }, 420); // After 420 ms
         return false;
     });
Post a Comment