I need the mouse cursor can auto show at the first input field of my custom form onload. I tried many method and they don’t work. I have tried the code below.
cur_frm.cscript.custom_onload = function(doc,dt,dn) {
$(‘form:first *:input[type!=hidden]:first’).focus();
}
But it only focus on the search field of header.
I also tried
cur_frm.cscript.custom_onload = function(doc,dt,dn) {
$(“input[data-fieldname=‘industry’]”).focus()
}
it also can not work.
I find to auto focus the first input field at childtable is OK. If any one can help me?
@jschen889 use
frappe.ui.form.on("My DocType", "onload", function(frm, cdt, cdn){
frappe.ui.scroll("[data-fieldname='myfield']");
});
Dont forget of replace My DocType
by the doctype
and myfield
by the name of the first field on screen.
1 Like
Max, Thanks for your code. It is so sorry. I have tried your code and it can not work. After I updated new code, the form become blank page.
frappe.ui.form.on(“Bags Location”, “onload”, function(frm, cdt, cdn){
frappe.ui.scroll(“[data-fieldname=‘lotno’]”);
});
Does it related to the version? I use V5.
Sorry, it is the same situation.
frappe.ui.form.on(“Bags Location”, “refresh”, function(frm, cdt, cdn){
frappe.ui.scroll(“[data-fieldname=‘lotno’]”);
});
unreachable code after return statement desk.min.js:868:187
TypeError: $(…).offset(…) is undefined
Thank you.