Site Meter
 
 

Knockout 2.1.0 released

Last night we released version 2.1.0 of knockout.js. This brings a whole bundle of added functionality and performance improvements. For a more detailed rundown of what’s new, see Ryan Niemeyer’s blog post.

With this release we welcome new core team member Michael Best, who implemented a lot of the 2.1.0 goodness. One of my favourite new features is the $index context variable. Here’s a short usage example:

The cool thing is that $index is an observable and is updated automatically as you add or remove items in any collection bound to a foreach (and so your UI will update to match). Impressively, Michael was able to add this new functionality while simultaneously improving the performance of foreach whether or not you are using $index!

We also benefited from pull requests, issue reports, and feature suggestions from many others in the community. Special thanks to neonstalwart and mtscout6 for not only implementing AMD module loader support and putting up with a lot of questions from me, but even including full documentation pages in their pull request – flawless OSS etiquette!

Again, if you want to know more about what’s new in KO 2.1.0, head on over to Ryan’s post for a full rundown.

10 Responses to Knockout 2.1.0 released

  1. Congrats! The $index feature was one of the missing pieces in the binding system…so this really rounds things out very nicely. I’m currently working on preparing an alpha of Durandal, which is built on top of Knockout and provides a Caliburn.Micro style approach to building single page apps. Hope to share it soon!

  2. Graeme Christie

    Excellent news Rob. I’m a big fan of Caliburn. Great to see that the Durnadal project is back on the radar again.

  3. szabi

    Will index work inside a data-bind block? Like css: {odd: $index%2} or function(){return $index%2} ?

  4. Ondrej

    @szabi: I think, this is right way: ‘css: {odd: $index() % 2}’….If $index is observable as was said.

  5. Lars Sandström

    Is it possible somehow to execute something like this:

    $(‘textarea’).autoResize();

    When new items are added in the viewmodel?

    Slowly moving over more and more to knockoutjs only forms :P

  6. This is looking really great! I am going to try it!

  7. Carl

    awesome! ‘$index() + 1′ also worked. keep up the good work :)

  8. szabi

    You’re right @Ondrej, $index() % 2 indeed works, thank you!

  9. Gene

    Hi there! Thank you for this excellent tool. I’ve just discovered it as a tool I could use in my Webapp 2.0 re-architecturing study (scope: client + server architecture, providing ultimate UX experience using one page app tech, enterprise size). Since I have the luxury not to have used the previous versions, I take KO 2.1.0 for granted as an excellent way to bidirectionally hook up ui with model in a clear & concise declarative way. I however miss a good enterprise model framework (Rest api automation, class derivation + extention, routing, enterprise reusable partial model factory (xtrn tmpl), etc etc), and am wondering what the KO teams roadmap is for that issue. I’ve seen an interesting achievement like knockback, combining the power of KO and backbone, but rather rely on something supported by the core team(s) in order to ommit as much refactoring over time as the libs mature. Did I miss a clear roadmap and/or what’s the best approach to connect with people tackling the same subject?

  10. Gene

    Just listened to the 013 JSJ podcast and understand currently KO wants to be agnostic to the persistency layer (for now at least, I get the safety of that choice in the fast changing market). Some good points to dive into are probably the mapping and/or meteor plugins and the upshot.js efforts of the MS team. I too aim a asp.net SS tech, albeit everything before MVC4 webapi/SPA I consider old skool not able to deliver the UX I aim for. @Steve: nice picks @JSJ, typical picks of the enlightened mind :)