Here’s what I have working for a PIN login form I’m using. The interval is set because I don’t know exactly when the form will be shown, since this was written as reusable code; sometimes it’s shown right on the page, sometimes it’s in a dhx.Window opened by a button. If your form is visible on page load, you could maybe simplify it a bit.
Note that this only applies the “onEnter” functionality to a single input field. I think the onEnter applied to the entire form in older versions of DHX. If you need it for the whole form, maybe you could grab an array of the form inputs, and do a forEach on the array to apply this eventHandler to each input.
var interval = setInterval(function(){
var el = document.getElementById("PIN");
if (el){
clearInterval(interval);
el.addEventListener("keyup",function(event){
if (event.keyCode === 13){ // "Enter" key
el.blur();
setTimeout(function(){
document.getElementById("btnSubmit").click();
},100);
}
});
}
},300);
The setTimeout() before doing the button click is there to allow time for the form field time to finish setting the value. Without it, the value of the field was still empty at the time the button click happened, which meant my form was submitting with no PIN value. I’m hoping the DHX dev team gets around to putting an onEnter event back into the form, so I’m putting up with the setInterval and setTimeout means of handling event timing for now. If the devs have a better way of doing it, I’d love to see it.