I have recently started to develop Win8 apps with HTML/CSS/JS. After 2 weeks a question regarding databinding with WinJS arose:
Is it possible to perform databindings via WinJS as powerful as with e.g. knockout.js(Can WinJS do all the things knockout can)?
If so, how would I perform an
ko.applyBindings()from knockout with just WinJS?
While "as powerful" is quite subjective, WinJS has a very capable binding engine. It's not the same, but shares some characteristics with Knockout. It's shares some details in some ways to the formerly-known-as Microsoft ASP.NET Ajax Library.
Here's one of their examples:
Every 500 millseconds, the
div will be updated to reflect the new
age of the
person. As it's taking advantage of ECMAScript 5's Object property getters and setters, the value of age can be easily tracked and then updated in the
There is a complete example with both the two approaches at the following posts:
Both methods are applied to the same ViewModel and everything is suppoorted (two way binding, converters etc).
One thing that's unfortuantely missing in WinJS is two-way databinding. So you have to write some code to get user input in the ui back into your view model.
©2020 All rights reserved.