SlideShare a Scribd company logo
Introduction to Knockout JsIntroduction to Knockout Js
Teena Vashist
Software Consultant
Knoldus Software LLP
Teena Vashist
Software Consultant
Knoldus Software LLP
AGENDAAGENDA
What is knockout js
MVVM
Features
Why knockout js
Observable
Controlling dependency tracking
Bindings
Demo
What is knockout js
MVVM
Features
Why knockout js
Observable
Controlling dependency tracking
Bindings
Demo
What is Knockout Js
● Knockout is a JavaScript library that helps you to create
responsive display(UI)
● It is based on Model–view–viewmodel (MVVM) pattern
● It provides a simple two-way data binding mechanism
between your data model and UI
● It was developed and is maintained as an open source project
by Steve Sanderson, a Microsoft employee on July 5, 2010
MVVM Design Pattern
MVVM pattern has 3 key parts:
● Model – It stores application data and is independent of any
UI
● View – It provides User Interface
● View-Model – It connect model and view and a pure-code
representation of the data and operations on a UI
MVVM
Features
● Declarative Bindings
It allows you to connect your UI element to your data model
● Automatic UI Refresh
When your data model's state changes, your UI updates automatically
● Dependency Tracking
Implicitly set up chains of relationships between model data, to transform and combine it
● Extensible
This implements custom behaviors as new declarative bindings for easy reuse in just a few lines
of code. Knockout is also flexible to integrate with other libraries and technologies
Why Knockout Js ?
● Small & lightweight - 54kb minified
● Compatible with other technologies
● Open source and free
● Smart feature - self updating UI
● Fully documented
● It supports all mainstream browsers:
IE 6+, Firefox 2+, Chrome, Safari, others
To create a view model with KO
Just declare any JavaScript object, For example
var employeeViewModel = {
empName: 'Teena',
empId: '12'
};
ViewModel holds
the UI's
underlying data
and behaviors
ViewModel inside a View
You can then create a very simple view of this view model
using a declarative binding.
Name is <span data-bind="text: empName"></span>
Binding attribute
DOM element with model
properties
Activating Knockout Js
ko.applyBindings(employeeViewModel);
Here, view will display like you would have written following
html
Name is <span>Teena</span>
Activate Knockout
Observables
These are special JavaScript objects that can notify subscribers about
changes, and can automatically detect dependencies.
Rewrite the preceding view model object as follows:
var employeeViewModel = {
empName: ko.observable('abc'),
empId: ko.observable(49)
};
Read/Write Properties of Observable
● To read: employeeViewModel.empName()
● To write: employeeViewModel.empName('Teena')
● To write value to multiple observable:
employeeViewModel.empName('bob').empId('15')
Computed Observable
Computed observable are functions that are dependent on one or more other
observables and will automatically update whenever any of these dependencies
change.
var empDetail =
ko.computed(function() {
return employeeViewModel.empName() +
" employee id: " + employeeViewModel.empId();
});
Controlling Dependencies
● Knockout’s automatic dependency tracking. But we might sometimes need to
control which observables will update your computed observable.
var empDetail =
ko.computed(function() {
return employeeViewModel.empName() +
" employee id: " +
employeeViewModel.empId.peek();
});
Knockout Bindings
● Controlling text and appearance:
visible, text, html, css, style, attr
● Control flow:
foreach, if, ifnot, with ,component
● Working with form fields:
click, event, submit, enable, disable, value, textInput etc.
Demo
https://github.com/knoldus/play-knockout-demo
Questions ?
References
● http://knockoutjs.com/
● http://www.knockmeout.net/
● https://msdn.microsoft.com/
Introduction to Knockout Js

More Related Content

What's hot (20)

PPTX
JAVASCRIPT PPT [Autosaved].pptx
AchieversIT
 
PDF
Dot net syllabus book
Papitha Velumani
 
PDF
AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)
Amazon Web Services Japan
 
PDF
Spring Boot
Jaran Flaath
 
PDF
Server-Side Rendering (SSR) with Angular Universal
Katy Slemon
 
PDF
Front-End Frameworks: a quick overview
Diacode
 
PDF
Vue.js
Jadson Santos
 
PPTX
Introduction to Spring Boot
Purbarun Chakrabarti
 
PDF
Intro to vue.js
TechMagic
 
PPTX
React js for beginners
Alessandro Valenti
 
PDF
마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...
Amazon Web Services Korea
 
PPTX
Asp.Net Core MVC with Entity Framework
Shravan A
 
PDF
AWS SQS for better architecture
Saurabh Bangad
 
PDF
Amazon SageMaker 모델 배포 방법 소개::김대근, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Amazon Web Services Korea
 
PDF
AWS Simple Monthly Calculator 操作説明書
Amazon Web Services Japan
 
PPTX
ASP.NET MVC.
Ni
 
PPTX
Introduction to HTML
Ajay Khatri
 
PDF
Complete MVC on NodeJS
Hüseyin BABAL
 
PDF
Next.js Introduction
Saray Chak
 
PDF
introduction to Vue.js 3
ArezooKmn
 
JAVASCRIPT PPT [Autosaved].pptx
AchieversIT
 
Dot net syllabus book
Papitha Velumani
 
AWS IoT Coreを オンプレミス環境と使う際の アーキテクチャ例 (AWS IoT Deep Dive #5)
Amazon Web Services Japan
 
Spring Boot
Jaran Flaath
 
Server-Side Rendering (SSR) with Angular Universal
Katy Slemon
 
Front-End Frameworks: a quick overview
Diacode
 
Introduction to Spring Boot
Purbarun Chakrabarti
 
Intro to vue.js
TechMagic
 
React js for beginners
Alessandro Valenti
 
마이데이터 사업자 핀다에게 듣다! - 핀테크의 AWS 활용 전략 - 이지영 AWS 솔루션즈 아키텍트 / 박홍민 대표, 핀다 :: AWS S...
Amazon Web Services Korea
 
Asp.Net Core MVC with Entity Framework
Shravan A
 
AWS SQS for better architecture
Saurabh Bangad
 
Amazon SageMaker 모델 배포 방법 소개::김대근, AI/ML 스페셜리스트 솔루션즈 아키텍트, AWS::AWS AIML 스페셜 웨비나
Amazon Web Services Korea
 
AWS Simple Monthly Calculator 操作説明書
Amazon Web Services Japan
 
ASP.NET MVC.
Ni
 
Introduction to HTML
Ajay Khatri
 
Complete MVC on NodeJS
Hüseyin BABAL
 
Next.js Introduction
Saray Chak
 
introduction to Vue.js 3
ArezooKmn
 

Viewers also liked (20)

ODP
Introduction to Apache Cassandra
Knoldus Inc.
 
ODP
Functional programming in Javascript
Knoldus Inc.
 
ODP
HTML5, CSS, JavaScript Style guide and coding conventions
Knoldus Inc.
 
ODP
Introduction to BDD
Knoldus Inc.
 
ODP
Deep dive into sass
Knoldus Inc.
 
ODP
Getting started with typescript and angular 2
Knoldus Inc.
 
ODP
Akka Finite State Machine
Knoldus Inc.
 
PDF
Rackow casandra ppp_slides
Casandra Rackow
 
PPTX
CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing A...
Farley Lai
 
PDF
Amazon Dynamo
Farley Lai
 
ODP
Drilling the Async Library
Knoldus Inc.
 
ODP
Getting Started With AureliaJs
Knoldus Inc.
 
ODP
Introduction to Scala JS
Knoldus Inc.
 
ODP
Akka streams
Knoldus Inc.
 
ODP
Realm Mobile Database - An Introduction
Knoldus Inc.
 
ODP
String interpolation
Knoldus Inc.
 
ODP
Mailchimp and Mandrill - The ‘Hominidae’ kingdom
Knoldus Inc.
 
PDF
Kanban
Knoldus Inc.
 
ODP
Shapeless- Generic programming for Scala
Knoldus Inc.
 
ODP
An Introduction to Quill
Knoldus Inc.
 
Introduction to Apache Cassandra
Knoldus Inc.
 
Functional programming in Javascript
Knoldus Inc.
 
HTML5, CSS, JavaScript Style guide and coding conventions
Knoldus Inc.
 
Introduction to BDD
Knoldus Inc.
 
Deep dive into sass
Knoldus Inc.
 
Getting started with typescript and angular 2
Knoldus Inc.
 
Akka Finite State Machine
Knoldus Inc.
 
Rackow casandra ppp_slides
Casandra Rackow
 
CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing A...
Farley Lai
 
Amazon Dynamo
Farley Lai
 
Drilling the Async Library
Knoldus Inc.
 
Getting Started With AureliaJs
Knoldus Inc.
 
Introduction to Scala JS
Knoldus Inc.
 
Akka streams
Knoldus Inc.
 
Realm Mobile Database - An Introduction
Knoldus Inc.
 
String interpolation
Knoldus Inc.
 
Mailchimp and Mandrill - The ‘Hominidae’ kingdom
Knoldus Inc.
 
Kanban
Knoldus Inc.
 
Shapeless- Generic programming for Scala
Knoldus Inc.
 
An Introduction to Quill
Knoldus Inc.
 
Ad

Similar to Introduction to Knockout Js (20)

PPTX
KnockOutjs from Scratch
Udaya Kumar
 
PDF
Knockout in action
Gerardo Leyes
 
PPTX
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
PPTX
Fundaments of Knockout js
Flavius-Radu Demian
 
PDF
Knockout Introduction
Sarvesh Kushwaha
 
PPTX
Knockout js
LearningTech
 
PPTX
Intro to Knockout.JS for Salesforce1
Boris Bachovski
 
PPTX
Knockout js
LearningTech
 
PDF
Knockoutjs
Yourcontent YC
 
PPTX
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
PPT
KnockoutJS and MVVM
Manvendra Singh
 
PPTX
Knockoutjs
Karthik Sathyanarayanan
 
PDF
Knockout mvvm-m1-slides
MasterCode.vn
 
PPTX
Knockout js
Andrey Kolodnitsky
 
PPTX
Knock out Introduction with samples (jsfiddle.net)
Balakrishnanan Ganesan
 
PPTX
Knockout.js
Vivek Rajan
 
PDF
An introduction to knockout.js
Emanuele DelBono
 
PPTX
Bringing the light to the client with KnockoutJS
Boyan Mihaylov
 
PPTX
Knockout (support slides for presentation)
Aymeric Gaurat-Apelli
 
KEY
KnockOutJS with ASP.NET MVC
LearnNowOnline
 
KnockOutjs from Scratch
Udaya Kumar
 
Knockout in action
Gerardo Leyes
 
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
Fundaments of Knockout js
Flavius-Radu Demian
 
Knockout Introduction
Sarvesh Kushwaha
 
Knockout js
LearningTech
 
Intro to Knockout.JS for Salesforce1
Boris Bachovski
 
Knockout js
LearningTech
 
Knockoutjs
Yourcontent YC
 
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
KnockoutJS and MVVM
Manvendra Singh
 
Knockout mvvm-m1-slides
MasterCode.vn
 
Knockout js
Andrey Kolodnitsky
 
Knock out Introduction with samples (jsfiddle.net)
Balakrishnanan Ganesan
 
Knockout.js
Vivek Rajan
 
An introduction to knockout.js
Emanuele DelBono
 
Bringing the light to the client with KnockoutJS
Boyan Mihaylov
 
Knockout (support slides for presentation)
Aymeric Gaurat-Apelli
 
KnockOutJS with ASP.NET MVC
LearnNowOnline
 
Ad

More from Knoldus Inc. (20)

PPTX
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
PPTX
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
PPTX
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
PPTX
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
PPTX
Java 17 features and implementation.pptx
Knoldus Inc.
 
PPTX
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
PPTX
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
PPTX
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
PPTX
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
PPTX
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
PPTX
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
PPTX
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
PPTX
Intro to Azure Container App Presentation
Knoldus Inc.
 
PPTX
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
PPTX
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
PPTX
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
PPTX
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
PPTX
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
PPTX
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
PPTX
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 
Angular Hydration Presentation (FrontEnd)
Knoldus Inc.
 
Optimizing Test Execution: Heuristic Algorithm for Self-Healing
Knoldus Inc.
 
Self-Healing Test Automation Framework - Healenium
Knoldus Inc.
 
Kanban Metrics Presentation (Project Management)
Knoldus Inc.
 
Java 17 features and implementation.pptx
Knoldus Inc.
 
Chaos Mesh Introducing Chaos in Kubernetes
Knoldus Inc.
 
GraalVM - A Step Ahead of JVM Presentation
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
Nomad by HashiCorp Presentation (DevOps)
Knoldus Inc.
 
DAPR - Distributed Application Runtime Presentation
Knoldus Inc.
 
Introduction to Azure Virtual WAN Presentation
Knoldus Inc.
 
Introduction to Argo Rollouts Presentation
Knoldus Inc.
 
Intro to Azure Container App Presentation
Knoldus Inc.
 
Insights Unveiled Test Reporting and Observability Excellence
Knoldus Inc.
 
Introduction to Splunk Presentation (DevOps)
Knoldus Inc.
 
Code Camp - Data Profiling and Quality Analysis Framework
Knoldus Inc.
 
AWS: Messaging Services in AWS Presentation
Knoldus Inc.
 
Amazon Cognito: A Primer on Authentication and Authorization
Knoldus Inc.
 
ZIO Http A Functional Approach to Scalable and Type-Safe Web Development
Knoldus Inc.
 
Managing State & HTTP Requests In Ionic.
Knoldus Inc.
 

Recently uploaded (20)

PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 

Introduction to Knockout Js

  • 1. Introduction to Knockout JsIntroduction to Knockout Js Teena Vashist Software Consultant Knoldus Software LLP Teena Vashist Software Consultant Knoldus Software LLP
  • 2. AGENDAAGENDA What is knockout js MVVM Features Why knockout js Observable Controlling dependency tracking Bindings Demo What is knockout js MVVM Features Why knockout js Observable Controlling dependency tracking Bindings Demo
  • 3. What is Knockout Js ● Knockout is a JavaScript library that helps you to create responsive display(UI) ● It is based on Model–view–viewmodel (MVVM) pattern ● It provides a simple two-way data binding mechanism between your data model and UI ● It was developed and is maintained as an open source project by Steve Sanderson, a Microsoft employee on July 5, 2010
  • 4. MVVM Design Pattern MVVM pattern has 3 key parts: ● Model – It stores application data and is independent of any UI ● View – It provides User Interface ● View-Model – It connect model and view and a pure-code representation of the data and operations on a UI
  • 6. Features ● Declarative Bindings It allows you to connect your UI element to your data model ● Automatic UI Refresh When your data model's state changes, your UI updates automatically ● Dependency Tracking Implicitly set up chains of relationships between model data, to transform and combine it ● Extensible This implements custom behaviors as new declarative bindings for easy reuse in just a few lines of code. Knockout is also flexible to integrate with other libraries and technologies
  • 7. Why Knockout Js ? ● Small & lightweight - 54kb minified ● Compatible with other technologies ● Open source and free ● Smart feature - self updating UI ● Fully documented ● It supports all mainstream browsers: IE 6+, Firefox 2+, Chrome, Safari, others
  • 8. To create a view model with KO Just declare any JavaScript object, For example var employeeViewModel = { empName: 'Teena', empId: '12' }; ViewModel holds the UI's underlying data and behaviors
  • 9. ViewModel inside a View You can then create a very simple view of this view model using a declarative binding. Name is <span data-bind="text: empName"></span> Binding attribute DOM element with model properties
  • 10. Activating Knockout Js ko.applyBindings(employeeViewModel); Here, view will display like you would have written following html Name is <span>Teena</span> Activate Knockout
  • 11. Observables These are special JavaScript objects that can notify subscribers about changes, and can automatically detect dependencies. Rewrite the preceding view model object as follows: var employeeViewModel = { empName: ko.observable('abc'), empId: ko.observable(49) };
  • 12. Read/Write Properties of Observable ● To read: employeeViewModel.empName() ● To write: employeeViewModel.empName('Teena') ● To write value to multiple observable: employeeViewModel.empName('bob').empId('15')
  • 13. Computed Observable Computed observable are functions that are dependent on one or more other observables and will automatically update whenever any of these dependencies change. var empDetail = ko.computed(function() { return employeeViewModel.empName() + " employee id: " + employeeViewModel.empId(); });
  • 14. Controlling Dependencies ● Knockout’s automatic dependency tracking. But we might sometimes need to control which observables will update your computed observable. var empDetail = ko.computed(function() { return employeeViewModel.empName() + " employee id: " + employeeViewModel.empId.peek(); });
  • 15. Knockout Bindings ● Controlling text and appearance: visible, text, html, css, style, attr ● Control flow: foreach, if, ifnot, with ,component ● Working with form fields: click, event, submit, enable, disable, value, textInput etc.