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.
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!
A little Explanation : I am using List view control of kendo UI(Telerik). I am triggering an update event of that control after editing the fields in list view. The list view control is having some text-boxes, a dropdown,checkbox and a submit button. When a user change something, ideally it should trigger update but its not doing update because control is not able to judge if there is a change in model.
It is only working if I input something in textbox and just click on outside of textbox i.e just do a onblur before hitting submit. I don't know why it is happening but what I need is to just trigger a focus event but in a hidden mode so that user is unaware of it but it just happens after a user input something in textbox so that the list view control works successfully.
I am trying to do it like below but it will get noticed to user. How can i trigger focus in hidden mode after a user just enter something in textbox before hitting a submit?
function BlurFunc() {
debugger;
$(this).closest('li').find('.inputField').focus();
}
Without your code it is not clear whether you are using MVVM data binding to your model, but this may help; from http://docs.telerik.com/kendo-ui/framework/mvvm/bindings/value:
By default the value binding relies on the change DOM event, which is
raised after blurring the element whose value has changed. This means
that the value from the View-Model is updated when the element loses
focus. The data-value-update attribute can be used to specify a
different DOM event, such as keyup or keypress. The keydown event is
not supported, because the DOM element value is not yet updated when
that event triggers.
For example, try adding data-value-update="keyup" as an attribute to your text box input element:
<input data-value-update="keyup" data-bind="value: inputValue" />
This should then update the model value upon each key press and not wait until focus has been removed.
I have many controls(like texbox,telerik grid, dropdown and radio button) on one asp panel.Could someone help me in detecting changes in any control of asp panel while clicking submit button.
There might be a better way of doing this, but my suggestion would be:
Create a hidden field that has a default value of "False". This hidden field will tell us if the form has changed or not.
Then assigning any editable control the JavaScript OnChange event.
The OnChange event should call a simple method that sets the value of the hidden field to "True".
For example with jQuery it would be:
function FormChanged() {
$(".hiddenField").val("True");
}
Then when you submit you will be able to access the value of the hidden field to know wether the form has benn changed or not.
I have a knockout model with observable arrays bound to a table. I want to have a button that when clicked, doubles the focused textbox value. I want to do this without having a create a 'hasFocus' observable for every textbox or every ko observable. Couple of issues I experienced :-
if the button just edits the value of the textbox directly using jQuery, the ko value does not get updated. I need a way to tell the button to change the underlying value
if I focus on a textbox then click a button, the focus on the textbox is lost so client side also doesn't remember what textbox is focused
Do an event binding on input on both focus and blur, setting and clearing an observable which tracks what input is active.
When the button is clicked you know which value to double
Hi I am using a dojo select, I have a text box where a certain ID is entered and then based on what is chosen on the select box an action is performed. Now the problem is, suppose over two different requests the action remains the same and the id changes I cant trigger the function with the onChange event. How do i handle this? Even if the user opens the select box and chooses the same item as last time I want the function i've written to be called.
onchange fires when any option is changed of the combo box.In your case you are not changing the options so obviously that event will not fired.
You can try onclick instead.
Write the same code in onclick for the select element (however with some intelligent logic since onclick will keep on firing even before you are able to select any option which may not expected in your case..!).