Apply changes with binding - javascript

I am searching on how to firechange to an input field after applying changes using code. Here is the code:
Otable.getModel().setProperty("/Products(1)/Price",29)
How can i fire the change to the input field?

If you have specified the correct binding mode from model to view (one-way or two-way should work in this case) and bound the value of your input field to the property in the model, it should update automatically and you shouldn't have to fire any change to the input field manually.
If you implemented the data binding correctly, a change in the model should reflect to the input field and vice versa.
var oInput = new sap.m.Input({
value: "{/value}" // path to the property here
});
Take a look at this fiddle: https://jsfiddle.net/nkLtqa5p/
and also at this tutorial regarding data binding here: https://sapui5.hana.ondemand.com/#docs/guide/e5310932a71f42daa41f3a6143efca9c.html

Related

Which event is triggered when v model value is changing

I'm new to Vuejs and my requirement is to write a single functional globally to trigger whenever v-model value of my form elements are set. I tried to write this for element.onchnage but this is not working.
Can some one tell me which HTML event is triggered when the v-model value is set in vuejs ?
Hey Linu and welcome to SO.
Check out the docs for Form input bindings:
https://v2.vuejs.org/v2/guide/forms.html
There it says:
v-model internally uses different properties and emits different
events for different input elements:
text and textarea elements use value property and input event
checkboxes and radiobuttons use checked property and change event;
select fields use value as a prop and change as an event.
So instead of v-model you can do the following for inputs
<input :value="dataProperty" #input="dataProperty = $event.target.value" />

What is the complete list of events supported by angular's updateOn property of ngModelOptions?

The docs say
updateOn: string specifying which event should the input be bound to. You can set several events using an space delimited list. There is a special event called default that matches the default events belonging of the control.
The page mentions a few events: blur, default, submit. Are there any others? Is the full list documented anywhere?
As far as i know, you can bind any available DOM event to the updateOn property. see a full list here.
Having a look at the Source of ngModel, you can see that the options passed to updateOn will get bound to the actual element itself.
https://github.com/angular/angular.js/blob/master/src/ng/directive/ngModel.js#L1188
Angular Source:
if (modelCtrl.$options.getOption('updateOn')) {
element.on(modelCtrl.$options.getOption('updateOn'), function(ev) {
modelCtrl.$$debounceViewValueCommit(ev && ev.type);
});
}
You can now control for a form (or single form elements) when the
value or the validity is updated. This feature has been available in
AngularJS 1.x but missed in Angular 2+ so far. The following update
options can now be used in Angular 5 forms:
change: change is the default mode. By using this update option the form / form control is updated after every single change.
blur: the blur change mode is only updated the from values / validity status after a form control lost the focus.
submit: updates are only done after form submit.
Full source is here.

EmberJS Handle Bars Inputs

I have the following:
<span>{{m.search_type}}</span>
{{input value=m.search_type}}
I retrieve the search_type with
this.get(search_type) in the controller that handles the form submission.
However, when I change the input value, the value within the <span>..</span> will change. This is the defined behavior in the docs.
I want the span to be the title for the input field and to not change along with the value of search_type. Search type is dynamic so I can't just hardcode the value for {{m.search_type}}.
Is there a way to do this? I tried creating a EmberJS Helper to map the value to a new string but this still changes whenever search_type changes.
Properties are always bound by default. Use the unbound helper to unbind the property.
<span>{{unbound m.search_type}}</span>
{{input value=m.search_type}}

show validation message after user enters invalid value and focused out and then on keyup,using knockout validation

I am using knockout validation to validate the data before updating in db.
I am not so familiar with knockout validation.
"valueUpdate" in data-bind for an input box is with "afterkeydown", for which, each time i am giving some invalid value the message is coming up.
But I want to show the message after user first time focused out from the input box. After that I want to show the message on key up.
If I can set the valueUpdate after focus out from view model, this may help.
Since I am having other bindings in data-bind, I can't just add data-bind attribute from vm.
I checkedthis link.
Any idea how to do this?
Your fiddle example is using Knockout 2.3. If you use Knockout 3+ you can use the textInput binding.
The textInput binding links a text box () or text area () with a viewmodel property, providing two-way updates between the viewmodel property and the element’s value. Unlike the value binding, textInput provides instant updates from the DOM for all types of user input, including autocomplete, drag-and-drop, and clipboard events.
So instead of:
<input data-bind='value: emailAddress,valueUpdate:"keyup"' required pattern="#"/>
your binding would look like:
<input data-bind='textInput: emailAddress' required pattern="#"/>
Here is an updated fiddle:
https://jsfiddle.net/mx45nnL6/2/

ExtJs check if form values has changed

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.

Categories