Site Meter
 
 

Knockout 2.2.0 released

It’s been five months since the last significant Knockout release, so it’s about time for another! The core team and many contributors have been hard at work adding some sweet new features, performance upgrades, architectural improvements, and bug fixes. After all this, the final code file is smaller than the previous version :)

You can download Knockout 2.2.0 now from GitHub where we also have the source, and see the updated documentation and test suite.

What’s improved?

The theme for KO 2.2.0 was “all the small things”. We processed and closed many, many, many work items tracked on GitHub, fixed a bunch of niggly little issues, improved our code structure, and put in some enhancements we’ve been wanting for a while.

My favourite enhancement is that the foreach binding will now detect when you have reordered elements in an array, and will simply move the corresponding DOM elements into the new order (previously, a “move” was handled as an “add” and a “delete”). You don’t have to change your code to enable this – it just works, even if you’re moving, adding, and deleting multiple items as a single atomic operation. Example:

If you want to animate the movements of DOM nodes into their new positions, you can make use of the new beforeMove and afterMove callbacks.

We’ve also made some features work more like you might always have thought they should work. For example, the css binding can now attach programmatically-generated CSS class names to elements (previously, it was limited to toggling predefined CSS class names). Example:

Other improvements include: 

  • The with, if, and ifnot bindings have been enhanced to preserve their original DOM elements on initial binding, so they are lighter and won’t unnecessarily strip out any special behaviours inserted by third-party libraries. I know a lot of people asked for this.
  • The dependency detection mechanism is now smarter in many places to avoid registering subscriptions that would be unnecessary no-ops
  • Support for IE10 (well, we basically already supported it, but there was one edge-case issue with autocompletion that we fixed)
  • Improved AMD support (the ko variable is now available in the context of all custom binding handlers, even if it isn’t in global scope)
  • The text binding can now be used in a virtual element (e.g., <!--ko text: myValue--><!--/ko-->)
  • Observable and computed properties have a new peek function for advanced control over dependency detection
  • Bugfixes

Big thanks to Michael Best and Ryan Niemeyer – my fellow KO core team members – and the many community members who contributed features, specs, and clearly-reproducible bug reports :)

32 Responses to Knockout 2.2.0 released

  1. Congratulations on the release! All your hard work is much appreciated.

  2. thank you! great work!

    In your sample above I can’t see where is chosenTicketCss comming from?!

  3. Excellent work! Can’t wait to upgrade with all the improvements

  4. Fredi Machado

    Awesome work! Thanks!

    @wordsearch: chosenTicketCss is a ko.computed in the javascrip.

  5. Thanks for these great improvements, and for all your good work. This is excellent news!

  6. Many thanks to you and the core team for your fanstastic work!

  7. alagesan palani

    I loved your auto detection feature of foreach. Thank you.

  8. The dynamic CSS names feature is useful for me. I’ll be applying that in my radio web app immediately. Thanks!

  9. Steve,

    Can you comment a little more on the purpose of Peek?

  10. @Chris Marisic – There is a new section in the documentation for computed that describes peek: http://knockoutjs.com/documentation/computedObservables.html#controlling_dependencies_using_peek

  11. Noel Abrahams

    All sensible changes.

    “The peek function lets you access an observable or computed observable without creating a dependency”.

    This is exactly what we wanted. Also, “withlight” and code-generated css class names are perfect additions.

    Excellent work, chaps.

  12. @Michael thanks I didn’t specifically look on the docs site, I tried to find info on google and wasn’t coming up with much. Must not have been picked up yet by the googles

  13. Jay Nimmala

    That is cool. I have been using knockout and any improvements to it is great. Thank you for all the hard work and continue the good work.

  14. Adrian

    That’s great news, thanks for the hard work!

    The ‘peek’ functionality is something I’ve recently discovered I need in some cases, so this is perfect timing for me :)

  15. Jimmy Harjadi

    Awesome, thanks for all your hard work.

  16. soryman

    First, thanks for your work. It”s great!
    But i copy codes of the webmail toturial ( link in your website:http://learn.knockoutjs.com/#/?tutorial=webmail) and run it from local file , the li:hover effect and circle corner don’t work in ie8(Firefox is ok) , while it works great at your online demo in both ie8 and firefox.
    Because i don’t know your email , so i have to post here. Sorry.

  17. Ariel

    Congratulations on the release! All your hard work is much appreciated. And now….please I have one issue/question – My app include few dynamic dialogs (jquery ui) and all of the viewModels declarations and applyBindings commands is happening in the dialog’s source. I notice that after few opening and closing dialogs – the browser’s memory increase. My question is – How is the best way to dispose or remove the bindings in the dialog’s close event ? is it – ko.removeNode ? or ko.clearNode ?

  18. Joshua Beall

    Great news! And I’m looking forward to the ASP.NET CDN hosted version being available. As of right now (8:50 AM US Eastern, Nov 5th 2012), the latest Knockout version hosted on the ASP.NET CDN is 2.1.0. Link to check the current status:

    http://www.asp.net/ajaxlibrary/cdn.ashx#Knockout_Releases_on_the_CDN_10

    -Josh

  19. Peter Munnings

    Hi Steve,

    Really battling with dates and Web Api. Posted this question (http://stackoverflow.com/questions/13359132/knockout-js-and-asp-net-web-api-dates) I’m sure you’ve solved this.

    Please can you point me in the right direction on this.

    thanks

  20. Thanks so much guys, you make my life soo much easier. Knockout.js is the future of web apps.

  21. Alain Dellon

    You forgot to mention the new $element

  22. Hello,Steven
    I am Gabriel,I am a Chinese .NET programmer. Last months,I have read your book 《Pro ASP.NET MVC 3 Framework》.I want to tell you that I love this book very much,it is a wonderful book,and I have read every word about this book,and I write detailed notes about the book in chinese。To share with the most Chinese programmers that want to study MVC3,I have posted the notes in my blog。If you will,I want to apply for the authorization,I just release the notes in my blog,hopes that can help most Chinese programmer study mvc3. I promise you that do not for any commercial use. Thank you! I look forward to your reply

  23. This question is about another thing, but I didn’t find where can I wrote this for you.

    What is your opinion about Dart language?

  24. I just wanted to say a big Thanks!
    Knockout is making Javascript a pleasure to work with!

  25. Basavaraj

    I have created a Page with Pagination option.
    Code looks same like : http://blog.ryanvanderpol.com/index.php/2012/07/using-knockoutjs-to-create-an-edit-in-place-data-grid/

    Now am not able to add sorting to the dependentObservable PagedList Data in knockout js

    because PagedList is not having Sort() prpoerty ..

    Pls help me

  26. Thanks for sharing very Important topic. So please keep up.

  27. Thanks Stephen,

    I’ve been using Knockout since the first release. I’ve tried other frameworks but nothing compares.

  28. Excellent work! Can’t wait to upgrade with all the improvements

  29. dzukjcmph, Where can i buy kamagra, peYjFaA, [url=http://yourkamagraguide.com/]Kamagra jelly[/url], jdCGQKX, http://yourkamagraguide.com/ Kamagra, MPaKzEC.

  30. Thanks , I’ve just been searching for info about this subject for ages and yours is the greatest I have came upon till now. However, what about the bottom line? Are you positive concerning the supply?