Use Custom Events for Page

Any idea for how to use custom events (field based) for page. I tried to use jquery’s on _change event but that also didn’t worked.

Any help will be hugely appreciated

Hi @nikzz,
I think this is what you want:

For more info about hooks: https://frappe.io/docs/user/en/guides/basics/hooks
:slight_smile:

Yes but those custom fiel events arent working for Page I had created. Thise events are working fine in Doctype but I’m working on Page

Ho My bad, didn’t read the title well enough.
Can you share what you have so far?
If you want a work around, you can use the before_save event, but I know it’s not optimal…

I cant access the code right now but the events which is working is as

frappe.pages['customer'].refresh= function(wrapper){
} 

All these events are working but on_change or custom event(fieldname) aren’t. Also since its a page, there’s no use of Save that’s why before_save wont be helping me here.

Thanks in advance

1 Like

Any clues / suggestions ?

This is what I came up with. But there’s one issue, it is printing twice in console.


frappe.pages['customer'].on_page_load = function(wrapper) {
        var page = frappe.ui.make_app_page({
                parent: wrapper,
                title: 'Customer',
                single_column: true
        });

        frappe.show_alert('Hey '+frappe.session.user,3)


        page.custom_field = page.add_field({
                fieldname: 'customer',
                label: __('Customer'),
                fieldtype: 'Link',
                options: 'Customer',
                change: function(){
                        console.log('first time')
                }
        });

 }

Can anyone help/suggest why it is printing twice.

Also I tried with refresh event but that also is doing the same

I am also very interested with what’s available for the customization on Page.

Can I ask did you have progress on this topic (except ‘page.add_field’)?

And I have experienced the same issue with erpnext scripts manager seems running ‘on_page_load’ twice.

Thank you!

Is Your problem “printing twice in console” is solved ?
if not
Check out code like this is Written twice in your “on_page_load” Event
{ var page = frappe.ui.make_app_page({
parent: wrapper,
title: ‘Customer’,
single_column: true
});