Question

I've recently been using Steve Sanderson's knockout js library http://knockoutjs.com/ in my client side web development. I just recently found out that microsoft has contributed code to jQuery for a Data Link plugin that seems to duplicate what I like about knockout.

http://weblogs.asp.net/scottgu/archive/2010/10/04/jquery-templates-data-link-and-globalization-accepted-as-official-jquery-plugins.aspx
https://github.com/jquery/jquery-datalink
http://api.jquery.com/category/plugins/data-link/

Should I scrap my knockout code and go with the embraced and extended jQuery?

Was it helpful?

Solution

I'd stick with Knockout personally -- it's already been demonstrated to work quite well, it's in active development, and it knocks data-link off the charts when you compare features. In short, Knockout seems ready for prime time, while data-link feels unfinished.

(I stress tested Knockout by having it data-bind a dropdown to an array of 5,000 items, while also calculating the number of unique items in the array and adding that to another data-bound element. My calculations and the re-painting of the browser chrome took far longer than the data-binding and updating.)

Now, that being said, I would keep an eye on data-link and probably continue to play around with it -- if it gets off the ground, it will be a very viable alternative. (Given the success of jquery-tmpl, the other major piece to come out of the Microsoft-Jquery cooperation.)

The better one to compare Knockout to would be documentcloud's backbone. I'm looking into backbone next week, so I don't have any good recommendations for now, but I've been very impressed with underscore (another of their projects), so I would definitely recommend looking into it as an alternative.


The score 4 years later
for those who are wondering

Knockout has been used in production on all kinds of projects for years, is now at version 3, and has a healthy ecosystem around it. jQuery.datalink became JSViews, which is still in beta.

OTHER TIPS

I've been doing some serious digging into Knockout, and I'm finding it reliable and extensible. Once you get into the mindset, I think it's the best developer experience I've seen in the browser.

Please notice that jQuery data link only works on Form elements. Knockoutjs work on many other types of bindings, such as attributes, css, which is very useful.

ko is useful for model pubsub to forms. To use widgets, one must write custom bindings. ko doesn't support AJAX directly.

backbone is useful for model persistence via RESTful JSON. It supports model/view sync weakly: model->view via JS template. view->model via widget handlers one must code.

ko & backbone don't support validation directly. (I don't count bb's model.validate() since one must write code to validate each attribute.) They don't have a data type concept. (extjs models have types and validation. Unfortunately, I've found extjs to be unreliable and inconsistent (data binding is integrated into the grid but not the form or property sheet; type information must be entered on grid cols and form fields though it is already present on the model).)

Even if one mixes ko, backbone, and jquery validation, there's a lot of code to write.

The most productive UI framework I've found is JSF2 since it handles all of this. Unfortunately, in practice it has problems.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top