Hi I have a jqGrid setup and I am trying to set the focus on one of my input boxes after the Edit Form loads. My code is as follows:
ondblClickRow: function (rowid) {
$(this).jqGrid('editGridRow', rowid, { left: '250', afterShowForm: function (formid) {
console.log('Bong');
$('elementID').focus(); }
});
The “Bong” is displayed, the event triggers, but the focus command doesn’t seem to work, and my google-fu doesn’t seem to be coming up with an answer for why this wouldn’t be working.
Thank you in advance.
EDIT:
My code with a $(‘#elementID’).focus(); still did not work so I implemented Oleg’s delay suggestion below and it started to work the way I wanted it to.
It seems to me that you have just typing error in your code: you should use
instead of
In some situations it’s needed to place the code in
setTimeout(function() {/*here*/}, 50);block, but I think it’s unneeded in your case.