How to trigger change event on field
- chris.cook
- Posts: 20
- Joined: Wed May 31, 2017
Hi,
I have a form where many fields get filled in automatically from various AJAX requests. Upon returning and filling in their values, I need to trigger the change event on those fields, in order to complete more logic.
Currently setting the value of a FD field doesn't trigger the change event, nor does using the jquery style fd.field(fieldname).change(), or fd.field(fieldname).control()._el().change()
I thought that one of them would do it, but I can't seem to programmatically trigger the event. The only way I can think of doing it is attaching new functions as properties to the fd objects that require updates and manually calling that function when I update them, but if the functionality is already there I would rather not hack it like that.
What do I need to do in order to trigger the fd change event programmatically?
I have a form where many fields get filled in automatically from various AJAX requests. Upon returning and filling in their values, I need to trigger the change event on those fields, in order to complete more logic.
Currently setting the value of a FD field doesn't trigger the change event, nor does using the jquery style fd.field(fieldname).change(), or fd.field(fieldname).control()._el().change()
I thought that one of them would do it, but I can't seem to programmatically trigger the event. The only way I can think of doing it is attaching new functions as properties to the fd objects that require updates and manually calling that function when I update them, but if the functionality is already there I would rather not hack it like that.
What do I need to do in order to trigger the fd change event programmatically?
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, Chris!
In order to trigger change you need to use this code:
But in order to detect change use this code:
Be careful with this code, as it should work for some fields, but not for all. If you have any difficulties with some types of fields, let us know.
In order to trigger change you need to use this code:
Code: Select all
fd.field(fieldname).control()._el().find('input').trigger('change');
Code: Select all
fd.field(fieldname).control()._el().find('input').on("change", function(){
//your code
});
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 6 guests