KnockoutJS Starter
Copyright 2012 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2012
Production Reference: 1161112
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78216-114-1
www.packtpub.com
Credits
Author
Eric M. Barnard
Reviewer
Roy Jacobs
Acquisition Editor
Mary Nadar
Commissioning Editor
Yogesh Dalvi
Technical Editor
Vrinda Amberkar
Project Coordinator
Amigya Khurana
Proofreader
Mario Cecere
Graphics
Valentina D'Silva
Aditi Gajjar
Production Coordinator
Melwyn D'sa
Cover Work
Melwyn D'sa
Cover Image
Conidon Miranda
About the author
Eric Barnard is a Software Engineer in Champaign-Urbana, Illinois. He truly feels that a great day starts with a fresh pot of coffee and a blank JavaScript file on his computer screen.
Eric grew up on a farm in central Indiana, where he attended Purdue University. After graduating from Purdue, he sharpened his web development and startup skills as a Fellow in the Governor Robert Orr Fellowship in Indianapolis. At the time of this writing, Eric has recently got married and spends his free time attempting to keep his wife sane. He is the author of the Knockout Validation plugin and "KoGrid" a JavaScript DataGrid completely built on top of Knockout. You can find his blog at http://www.ericbarnard.com.
About the reviewer
Roy Jacobs is a Software Architect in Utrecht, the Netherlands. Wrangling C# and JavaScript is just as interesting as moving an icon two pixels to the left to improve the user experience.
Roy received his Bachelor's in Computer Science from the Fontys Polytechnic in Eindhoven and his Master's in Human-technology Interaction from the Technical University of Eindhoven. Apart from the technical stuff he dabbled in directing and visual effects and enjoys spending time with his girlfriend and their hamster.
He is the author of the Knockout Mapping plugin and his blog can be found at http://www.royjacobs.org.
www.PacktPub.com
Support files, eBooks, discount offers and more
You might want to visit www.PacktPub.com for support files and downloads related to your book.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at > for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
www.PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
- Fully searchable across every book published by Packt
- Copy and paste, print and bookmark content
- On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view nine entirely free books. Simply use your login credentials for immediate access.
Chapter 1. KnockoutJS Starter
Welcome to KnockoutJS Starter . This book focuses on giving the reader a firm understanding of the core concepts of Knockout, such as MVVM and data binding, and works through real-life app development scenarios. All core components of Knockouts amazing library are covered in detail, and strategies are outlined for getting the best use of time when developing with Knockout.
This book contains the following sections:
- So, what is Knockout? In this section you will get to know what Knockout does and how you might start to benefit from its functionality.
- Installation In five easy steps, you will see how you can be ready to start developing with Knockout.
- Quick start In this section you will learn to use Knockout to build an often needed business tool an inventory management app.
- Top features you need to know about This section illustrates Knockouts numerous extension points and plethora of utilities to help smooth the process of building your app.
- People and places you should get to know Knockouts core development team is continually adding features and resources to help developers. You will learn, in this section, how to access Knockouts community and stay up to date in the future.
So, what is Knockout?
In this section you will get to know what Knockout does and how you might start to benefit from its functionality.
Knockout A JavaScript library
Knockout, at its core, is a simple JavaScript file that can be included in a website or a web application to add JavaScript functionality, and provides the ability to enhance a user's experience. By default, Knockout does nothing to your website or web application until you specifically write code to utilize it. It is important to understand the difference between Knockout and many other JavaScript "frameworks" or "libraries" as some frameworks actually change how a website or web application works when included.
Knockout A Model-View-ViewModel (MVVM) library
One of the reasons that Knockout was created was for the specific goal of enabling Model-View-ViewModel ( MVVM ) style development for websites and web applications. MVVM is a style of development where different object classes are designed to separate user-interface logic from business functions for testability purposes.
We strive to write testable code for many reasons (which is a topic for an entire other book), but the biggest reasons are maintainability of the code base and improved quality assurance. As I've learned to write code in a testable way, I've seen my code bases become more idiomatic and easier to maintain. If anything, building JavaScript applications with the MVVM pattern has allowed me to deliver more reliable applications in a shorter time period compared to when I was simply trying to sprinkle my HTML pages with DOM event handlers and unorganized pieces of logic.