Search code examples
javascriptxpages

Unable to put focus on a field after closing dialogbox


In my XPages application I am trying to set focus on a field that is a bootstrap date picker after a dialog box is closed:

XSP.closeDialog('#{id:dlgLMAValidDate}');
//I thought this would work but is does not
//$('#{id:inpLMAValid}').focus();
//alternative attempt:
//does not work either
var el = XSP.getElementById('#{id:inpLMAValid}');
var ef = dojo.byId(el);
ef.focus();

I wonder what I am doing wrong?


Solution

  • the following works for me:

    XSP.closeDialog('#{id:dlgLMAValidDate}');
    var el = XSP.getElementById('#{id:inpLMAValid}');
    el.focus();
    el.scrollIntoView();