ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Input Dom is not ready on frappe.ui.form.on refresh


#1

Hi guys,

Currently I am developing a Frappe application. Let say I have a Driver doctype, and want to get the input dom element in refresh.

Please take a look at the following script on ‘Driver.js’:

    `frappe.ui.form.on('Driver', {
    	refresh: function(frm) {
    		console.log('instance of', 'frm.fields_dict.full_name.input is', frm.fields_dict.full_name.input);

    	}
    });`

Output:
instance of frm.fields_dict.full_name.input is undefined

Expected output:
instance of frm.fields_dict.full_name.input is <input type="text" autocomplete="off" class="input-with-feedback form-control" maxlength="140" data-fieldtype="Data" data-fieldname="full_name" placeholder="" data-doctype="Driver">

It was fine until the latest version of Frappe.
Please advise.

Thanks,
Pujianto


#2

It’s still undefined on onload trigger, though


#3

I think every input is undefined unless they have value. correct me if i’m wrong.


#4

Hi Magic Overflow,
Thanks for the response, I am afraid not.
I suspect the script is executed before the dom is fully loaded. If we run the script on Developer Console through cur_frm, it’s resolved.


#5

Sorry I was wrong. I misunderstood with read-only field which undefined when it has no value.


#6

Update:
It now works on Frappe master branch. May be it can be considered as a bug?
If you guys facing the similar issue, I recommend to switch to master branch.

Thanks,
Pujianto