In Page DocType why is change event called twice?


I have create a Page DocType.

In this page I have place the code

let inspection_status = page.add_field({
		label: 'Inspection Status',
		fieldtype: 'Select',
		fieldname: 'inspection_status_list',
        //default: 'All',
		options: [
		change() {

But when a user selects an item the Select’s change event is called twice.

Why is this happening?

Will this affect performance as I am fetching a lot of data using multiple joined SQL statement?


Yogi Yang

1 Like

I have noticed the same behaviour.

Is defining change() within the inspection_status object and referring to it for it’s own definition correct : inspection_status.get_value()

Is change() the only event we can use?

Also Use Custom Events for Page - #7 by nikzz

1 Like


Thanks for the link.

I checked the thread but it did not help solve the problem that I am also facing just like @YogiYang.

It’s because the change event is being triggered twice when the option is selected and when the field is blurred.

You can try the below approach.

var is_focused = $(`.page-form [data-fieldname='${field}']`).is(":focus")
     $(`.page-form [data-fieldname='${field}']`).blur();
    // your code here