Hello,
there is a plugin to work with Knockout with ES5 compatible browsers:
http://blog.stevensanderson.com/2013/05/20/knockout-es5-a-plugin-to-simplify-your-syntax/
It does not work correctly with igEditors. The editors get their value through Knockout but do not write the value back.
Here is a fiddle to demonstrate the problem:
http://jsfiddle.net/SEHQt/3/
- Edit the plain inputs and the values update when moving focus.
- Edit the igEditors and the values do not update.
I need a fix ASAP because I am stuck with development with this bug.
Best regards,
Joern
Hello Joern,
Thank you for contacting Infragistics.
I have taken a look at your code. I believe you are having this issue as you are not marking anything as observable. Please see the following sample and jsFiddle to see an example of this:
http://igniteui.com/editors/bind-editors-with-ko
http://jsfiddle.net/gh/get/jquery/1.9.1/igniteuisamples/jsfiddle-samples/tree/master/EN/HtmlSamples/editors/bind-editors-with-ko/
Please let me know if you have any questions concerning this matter.
I know about the sample - that's what I based my code on.
All properties of the viewModel become observable with the following call in my code:
ko.track(viewModel);
If you read the documentation of the plugin (see the link in my original post), you will see that the plugin creates the Observables as the backing store for an ES5 property.
This - combined with the fact that Knockout can bind to any value or property on an object - makes it work.
If you run my sample, you can see that the standard controls work and bind correctly. Only the igEditors do not work.
To demonstrate why this issue has nothing specific to do with the ES5 plugin, I created a new Fiddle without ES5:
http://jsfiddle.net/tV6uM/1/
To reproduce:
- Start the fiddle
- Look at "Due in days" - both editors pickup the initial value "7" -> correct!
- Enter a value in the "Due in days" standard Input on the right, click on "Show Due in Days" - the alert box displays the value that you just entered - Correct! - That is the 1-way-binding working.
- Enter a different value in the igEditor "Due in days" field on the left, click on "Show Due in Days" - the alert box displays the old value!- Incorrect! Bug! - 1-way-binding is not working as it should!
Thank you for the update. I am currently discussing this further with our development team. We will continue to look into this matter and I will update you with my progress.
I have discussed this further with our development team and have the following information:
1-way-databinding means that the control can read the property but does not write to it. 2-way-databinding means it reads the property and whenever the control value changes writes back to the property.
The case that you explain is exactly the behavior that is described. The igEditor reads the property value, displays it, but when changed doesn’t change the property value because it expects a KO observable in order to do this.
Please let me know if you have any further questions concerning this matter.
Hello Mike,
1-way-binding could mean what you wrote but in this case it is the other way around. (In WPF/XAML it would be called "1-way-binding-to-source".)
The official Knockout documentation:
"However, if you use value to link a form element to a non-observable property (e.g., a plain old string, or an arbitrary JavaScript expression), KO will do the following:If you reference a simple property, i.e., it is just a regular property on your view model, KO will set the form element’s initial state to the property value, and when the form element is edited, KO will write the changes back to your property. It cannot detect when the property changes (because it isn’t observable), so this is only a 1-way binding."
According to the documentation it is actually a "one-time-binding-from-source" and a "1-way-binding-to-source".
And this is how all standard INPUT element bindings are implemented.
The igEditor implementation is not correct according to the official Knockout documentation, not according to my opinion. Try my jsfiddle and you can see the difference.
Thank you for your update. I have spoken further with our development team and have the following information:
Development is working on making the following change to the igEditor:
The igEditor will write back the property value when modified, however if the value is not observable no other element bound to this value would be notified on the change.
They are working on this matter hopefully have it in the next service release of the product as well as the v14.1 version release.