How load JavaScript code in All Doctype

I am using this :slight_smile:

// the following two handles will watch the page changes everywhere
$(window).on('hashchange', page_changed);
$(window).on('load', page_changed);

function page_changed(event) {
    // waiting for page to load completely
    frappe.after_ajax(function () {
        var route = frappe.get_route();

        if (route[0] == "Form") {
            frappe.ui.form.on(route[1], {
                refresh: function (frm) {
                    console.log("doctype =" + frm.doctype);
                }
            })
 

        }
    })
}
7 Likes