.change(call named function)

rss

Posted by Dan_C - Dec 16 ’14 at 06:08

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?

  • Dmitry Kozlov
    Dmitry Kozlov
    Admin
    Member for: 6 years 10 months 25 days
    #1 by Dmitry Kozlov Dec 17 ’14 at 04:32

    Hi,

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

    function OnFieldChanged() {
    	// your code here
    }
    
    fd.field('Field1').change(OnFieldChanged);
    fd.field('Field2').change(OnFieldChanged);
    
Displaying 1 to 1 of 1 messages