Page 1 of 1

.change(call named function)

Posted: 16 Dec 2014
by Dan_C
Hi Dmitry,

I'd like for several different fields to call the same function when any of them are changed.

This may relate to my inexperience in all this, but when when I put a previously (outside the change) named function inside the change() handler it seems to break after working once.

I don't have to repeat the same long function inside each change() do I?

Re: .change(call named function)

Posted: 17 Dec 2014
by Dmitry Kozlov
Hi,

Of course, not. You can define a single handler for multiple events this way:

Code: Select all

function OnFieldChanged() {
	// your code here
}

fd.field('Field1').change(OnFieldChanged);
fd.field('Field2').change(OnFieldChanged);