Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
WEB APP TESTING USING KNOCKOUT.JS

You're reading from   WEB APP TESTING USING KNOCKOUT.JS Design, implement, and maintain a fully tested JavaScript web application using Knockout.JS

Arrow left icon
Product type Book
Published in Nov 2014
Publisher
ISBN-13 9781783982844
Pages 154 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
ROBERTO MESSORA ROBERTO MESSORA
Author Profile Icon ROBERTO MESSORA
ROBERTO MESSORA
Arrow right icon
View More author details
Toc

The ViewModel in detail


A ViewModel is a pure-code representation of the View. We saw in the previous sections that it contains data to show and commands that handle events triggered by the user.

It's important to remember that a ViewModel shouldn't have any knowledge about the View and the UI. Pure-code representation means that a ViewModel shouldn't contain any reference to HTML markup elements (buttons, text-boxes, and so on.) but only pure JavaScript properties and methods.

Knockout.JS is a JavaScript implementation of the Model-View-ViewModel presentation design pattern whose objective is to promote a clear separation between the View and ViewModel. This principle is called Separation of Concerns.

Why is this so important? The answer is quite easy, because in this way a developer can achieve a real separation of responsibilities. The View is only responsible for presenting data to the user and reacting to her/his inputs. The ViewModel is also responsible for holding the data and providing...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime