is there a possibility to check if form values has changed in ExtJs?
Thanks
myForm.getForm().items.each(function(field){field.on('change',function(f,n,o){alert('detected! '+f.label+' value changed from '+o+' to '+n);});});
In the above snippet, what you are basically doing is -
Iterate over all fields in the form (myForm.getForm().items.each())
For each field, add a change listener. (field.on(...))
When a field's value is changed, the listener will be invoked with the field info and old and new value.
In the listener, change the alert with the appropriate logic.
Related
IN SHORT: Is there a javascript function or hook to trigger an update to a Gravity Form so that the conditional logic is executed?
ORIGINAL QUESTION:
I'm using Gravity Forms and I have created an "on change" event
$('#gform_1').find('.gfield_date_dropdown_month select').change(function () {
var month = $(this).val();
$('input#input_1_6').val(month).change();
});
After this event I would like Gravity Forms to check/update the form so that the "Conditional Logic" is being executed to related fields.
I have checked the hooks on https://docs.gravityforms.com/category/extending-gravity-forms/hooks/javascript
but I can't find a hook that I can use for this purpose. Any ideas?
UPDATE:
The field that is changed (#input_1_6) is "hidden". This seems to be the problem. When I make this field visible it does work! So a change to a "hidden" field does not seem to trigger the update to the form. If I would have a function that would trigger this update I could add it to my jQuery function.
Some background information on this issue. I want a field to become visible when a certain month is selected in a date field. Since Gravity Forms does not support "Conditional Logic" based on a date field I want to update a hidden field with the "month value" and then use that value for the "Conditional Logic" on a related field.
Gravity Forms conditionals are triggered with the click or change events, depending on the type of field. You can manually trigger the change event with the .change() method.
Note this isn't working because the conditional isn't tied to the field you attached a change event to, so you have to trigger .change() on the field that does have conditionals. Assuming field 1_6 is the field that triggers conditionals:
$('#gform_1').find('.gfield_date_dropdown_month select').on('change', function(){
var month = $(this).val();
$('#input_1_6').val(month).change();
});
Some other small notes, consider using .on('change', function(){} instead of .change(function(){} as it will trigger on dynamic elements - as well as you don't need input before #input_1_6 since it's already a unique element.
Cheers!
I use https://github.com/Dimox/jQueryFormStyler for styling form inputs.
I set the property ng-model="c.model.acept".
If I click on "styled checkbox", then input gets to property "checked", but the angular model still has the old value.
I tried to trigger the change event with no result.
If I trigger the click event, then the checkbox gets changed twice (once from click, and then the second time from the triggered click event).
How to fix it?
You can not change "ng-model" of particular input field conditionally.
In this condition what you can do is, keep two input field and use "ng-show" or "ng-if" attribute to show & hide input field conditionally.
Hope this will hep you.
I have a form with some input fields and all those fields have onchange triggered callbacks (which can be different depending on the field).
My problem is that when the form is submitted the focus is still on the last modified field and the onchange callback is not called for this field, which can lead to submit wrong values.
I am looking for a way to force the triggering on the onchange event for the last field modified but I can't determine which element it is from my submit function.
How can I achieve this ?
Try this
$focused_element = $(':focus');
if($focused_element.is('input')){
$focused_element.trigger('change');
}
here is my jsFiddle:
http://jsfiddle.net/YJqAu/
When the user clicks on the toggle, I'd like to know the current value of the input field. You can see from the logs that jQuery is not sending back the input field value. Why is that? Ideas?
Thanks
alert($('input', $(this)).val()); // echoed out 'on' for me
The input has no value, it is a checkbox. To get whether or not the checkbox is checked you can use $(this).is(":checked").
I'm using Dynamic Data 4 on my project.
In a template field there's a button that modify (via javascript) the value of the databound input field.
The button modify the input box value correctly but when the input field get the focus his value it's resetted to the previous value. The same happens when saving the form. If the input box previously received input from the keyboard the value it's correctly stored.
Is that behaviour to be considered normal with those premises? There's a way to avoid it?
Thank you very much.
The problem was caused by the presence of an associated asp:TextBoxWatermarkExtender who resetted the value when the (originally null) textbox got the focus.