O'Reilly logo

Knockout.js by Jamie Munro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Next Steps

The Simplicity of Knockout

The last chapter signified the conclusion of the code examples in this book. While I was working on the plan for this book, I thought the last chapter would contain a significant amount of more code. A shopping cart is not a simple thing to build, as it includes many components such as browsing categories, products, and tracking items the user adds to his shopping cart. I really hope this demonstrates how KnockoutJS fits into your projects and makes maintaining a state across a single web page really easy. The final view model for the shopping cart was less than 40 lines of code (including line breaks for readability)! The HTML that performs the necessary data bindings was also less than 40 lines of code! The way Knockout brings this together with simple user interactions makes those 80 lines of code extremely powerful.

The focus of this book was about learning the ins and outs of Knockout. I think every feature was covered. If I were to advance the shopping cart example, I would focus on the design. The current implementation looks quite plain, but with a little bit of styling, it would quickly take on a whole new appearance with little to no changes to the JavaScript. Of course, design is not my strong suit, so I’ll leave that to the designers!

Prior to using Knockout, I built heavy client-side user interfaces, and I can assure you that it involved significantly more than 80 lines of code. It involved complex jQuery to dynamically ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required