To do binding, the procedure is two steps. Since WinJS doesn't support two way bindings we need to define each one way binding.
The first from source data to the destination and is done via WinJS.Binding.defaultBind.
The second from the binding target back to the source data (in this case actually just from the input text box to the source model is done from an onchange event wiring.
WinJS.Namespace.define("Binding.Mode", { twoway: WinJS.Binding.initializer(function (source, sourceProps, dest, destProps) { WinJS.Binding.defaultBind(source, sourceProps, dest, destProps); dest.onchange = function () { var d = dest[destProps[0]]; var s = source[sourceProps[0]]; if (s !== d) source[sourceProps[0]] = d; } }) });
<input type="text" data-win-bind="value: name Binding.Mode.twoway" /<That's it - super easy.
This comment has been removed by a blog administrator.
ReplyDeleteI used two-way binding in WinJS when I worked with ux design company. This way is a more effective and easy for understanding. You only need right define each one way binding.
ReplyDeleteI like to read such news.
ReplyDeleteSexy Escort girls