Knockback.js: Knockout.js magic for Backbone.js
kmalakoff.github.com
kmalakoff.github.com
When I was evaluating client-side frameworks, I liked lots of the pieces, but wanted to "mix and match" the best features. I started with Backbone.js and really loved the Models and Collections, and used Brunch to get me up and running quickly.
After a while, I found the view coding too slow so I wrote Mixin.js to extract out reusable aspects of my views. When I was looking for my next productivity increase, an ex-work colleague suggested Sproutcore, but at the time, it wasn't yet micro-frameworky enough meaning I would need to learn something big and "to throw the baby out with the bathwater" as they say (it is hard to give up Backbone models and collections!). Then, I discovered Knockout and knew it was for me!
Knockout provided just the right building blocks for a layer between my templates and data. As I used it more, I built additional functionality like Backbone.ModelRefs for lazy model loading, localization helpers for truly dynamic views, and most recently, an easier way to sync collections and their model's view models.
So here it is...the refactored and shareable version of my Backbone bindings for Knockout: Knockback.js
It also seems that Angular.js is a natural progression from KO to something more full-featured (when needed).
I'm curious if you compared Knockback to Angular?
I'm going to propose the FuckThis paradigm until I can come up with something that makes some sort of sense.
If you consider, in Backbone.js, that your templates are the views, then the Backbone Views are a kind of controllers. What are the advantages of Knockback.js here? I'm sure there are but it's not clear to me given the description.
Alternatively in backbone.js you can create object models related to View but that are not part of your business logic.
- It makes a clear distinction between Views and logic by providing ViewModels. You don't need to have the a single class rendering data and processing logic also.
- Provides the data-bind based templating which cleans up the backbone.js render function that requires DOM manipulation through libraries like jQuery.
This is a simplified version of Backbone designed for use with Knockout and other client side rendering frameworks.
Disclosure: I'm the author
However, Knockout really excels at that, and allows you to do great live updates.
In the end, we chose Knockout + Sammy.js (history and routing) + manual templating (pretty easy really).
Can another provide examples of where one would be superior over the other?
Unfortunately I can't comment on backbone as I haven't used beyond tutorials, someone else might be able to assist though.
As a .NET guy, I'd go for Knockout. I also like what I'm seeing with Angular.
Uses RDFa annotations to automatically construct views and models.