SlideShare a Scribd company logo
1 of 22
Download to read offline
An introduction
to Knockout.js
Emanuele Delbono
@emadb
Everyone loves jumping in muddy puddles
Everyone loves jumping in muddy puddles
writing javascript code
We write tons of
javascript code
I am
Web Developer in
CodicePlastico. I have fun
writing web apps in C#,
Javascript and Ruby.
Agenda
• The MVVM Pattern
• Welcome to Knockout
• Binding basics
• The features
• Conclusions
Presentation
patterns
The MVVM pattern
Model ViewModel View
ViewModel has
methods too!
What is Knockoutjs?
“Knockout is a JavaScript library that helps you
to create rich, responsive display and editor user
interfaces with a clean underlying data model.
Any time you have sections of UI that update
dynamically [...], KO can help you implement it
more simply and maintainably.”
http://knockoutjs.com
Key features
• Declarative binding
• Automatic UI refresh
• Templating
• Dependency tracking
Bidirectional Data
Binding
ViewModel View
Binding
• data-bind attributes in HTML
• ko.observable() for the properties
• ko.applyBindings() to activate bindings
Binding
var viewModel = {
message: ko.observable('Welcome')
}
<div data-bind="text: message"></div>
Observable is a function!
Don’t do this:
viewModel.message = 'hi'
Do this:
viewModel.message('hi')
Code time
Recap
• Simple binding
• Array binding
• Computed
properties
• Event binding
• Conditionals
• Templates
• Subscriptions
• Messagging
• Contexts
• Custom bindings
• Virtual elements
Conclusions
• KO is small focused on binding
• Very low learning curve
• Focused on databinding (no routing,
model synchronization, etc...)
• Lots documentation
• Could be hard on big pages
https://github.com/emadb/jsday13

More Related Content

What's hot

KnockOutjs from Scratch
KnockOutjs from ScratchKnockOutjs from Scratch
KnockOutjs from Scratch
Udaya Kumar
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
Soós Gábor
 

What's hot (20)

KnockOutjs from Scratch
KnockOutjs from ScratchKnockOutjs from Scratch
KnockOutjs from Scratch
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
 
Levent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerLevent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & Polymer
 
A brave new web - A talk about Web Components
A brave new web - A talk about Web ComponentsA brave new web - A talk about Web Components
A brave new web - A talk about Web Components
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data Link
 
Knockoutjs
KnockoutjsKnockoutjs
Knockoutjs
 
Jqueryppt (1)
Jqueryppt (1)Jqueryppt (1)
Jqueryppt (1)
 
Introduction to backbone js
Introduction to backbone jsIntroduction to backbone js
Introduction to backbone js
 
Difference between java script and jquery
Difference between java script and jqueryDifference between java script and jquery
Difference between java script and jquery
 
Introduction to single page application with angular js
Introduction to single page application with angular jsIntroduction to single page application with angular js
Introduction to single page application with angular js
 
handout-05b
handout-05bhandout-05b
handout-05b
 
MVVM Lights
MVVM LightsMVVM Lights
MVVM Lights
 
MVVM Applied: From Silverlight to Windows Phone to Windows 8
MVVM Applied: From Silverlight to Windows Phone to Windows 8MVVM Applied: From Silverlight to Windows Phone to Windows 8
MVVM Applied: From Silverlight to Windows Phone to Windows 8
 
Bringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJSBringing the light to the client with KnockoutJS
Bringing the light to the client with KnockoutJS
 
Lesson 09
Lesson 09Lesson 09
Lesson 09
 
Os mobile
Os mobileOs mobile
Os mobile
 
Basics of VueJS
Basics of VueJSBasics of VueJS
Basics of VueJS
 
Javascript frameworks: Backbone.js
Javascript frameworks: Backbone.jsJavascript frameworks: Backbone.js
Javascript frameworks: Backbone.js
 
Javascript and DOM
Javascript and DOMJavascript and DOM
Javascript and DOM
 

Viewers also liked

An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
hchen1
 
Download presentation
Download presentationDownload presentation
Download presentation
webhostingguy
 

Viewers also liked (18)

Knockout.js explained
Knockout.js explainedKnockout.js explained
Knockout.js explained
 
jQuery in 10 minuten
jQuery in 10 minutenjQuery in 10 minuten
jQuery in 10 minuten
 
knockout.js
knockout.jsknockout.js
knockout.js
 
Knockout js
Knockout jsKnockout js
Knockout js
 
Knockout js (Dennis Haney)
Knockout js (Dennis Haney)Knockout js (Dennis Haney)
Knockout js (Dennis Haney)
 
Knockout (support slides for presentation)
Knockout (support slides for presentation)Knockout (support slides for presentation)
Knockout (support slides for presentation)
 
Knockout js
Knockout jsKnockout js
Knockout js
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Asp.Net MVC - Razor Syntax
Asp.Net MVC - Razor SyntaxAsp.Net MVC - Razor Syntax
Asp.Net MVC - Razor Syntax
 
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo Brugge
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo BruggeHTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo Brugge
HTML 5, ASP.NET MVC & Windows Azure sessie voor Ivo Brugge
 
Knockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingKnockout JS Development - a Quick Understanding
Knockout JS Development - a Quick Understanding
 
#2 Hanoi Magento Meetup - Part 2: Knockout JS
#2 Hanoi Magento Meetup - Part 2: Knockout JS#2 Hanoi Magento Meetup - Part 2: Knockout JS
#2 Hanoi Magento Meetup - Part 2: Knockout JS
 
An Introduction to Ajax Programming
An Introduction to Ajax ProgrammingAn Introduction to Ajax Programming
An Introduction to Ajax Programming
 
Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3Design for Developers: Introduction to Bootstrap 3
Design for Developers: Introduction to Bootstrap 3
 
Ajax Ppt
Ajax PptAjax Ppt
Ajax Ppt
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
Download presentation
Download presentationDownload presentation
Download presentation
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentation
 

Similar to An introduction to knockout.js

Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
Andoni Arroyo
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Jeremy Likness
 
Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0
Mayank Srivastava
 

Similar to An introduction to knockout.js (20)

Sugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a timeSugarcoating your frontend one ViewModel at a time
Sugarcoating your frontend one ViewModel at a time
 
Knockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockoutKnockout implementing mvvm in java script with knockout
Knockout implementing mvvm in java script with knockout
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
MVVM frameworks
MVVM frameworksMVVM frameworks
MVVM frameworks
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
 
Mean stack
Mean stackMean stack
Mean stack
 
Aspnet mvc
Aspnet mvcAspnet mvc
Aspnet mvc
 
Asp.net mvc 5 ppt
Asp.net mvc 5 pptAsp.net mvc 5 ppt
Asp.net mvc 5 ppt
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
 
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
Wintellect - Devscovery - Enterprise JavaScript Development 2 of 2
 
Mobile ASP.Net Web Forms - Making the impossible possible | FalafelCON 2014
Mobile ASP.Net Web Forms - Making the impossible possible | FalafelCON 2014Mobile ASP.Net Web Forms - Making the impossible possible | FalafelCON 2014
Mobile ASP.Net Web Forms - Making the impossible possible | FalafelCON 2014
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 days
 
Understanding The MVVM Pattern (TechDays Belgium)
Understanding The MVVM Pattern (TechDays Belgium)Understanding The MVVM Pattern (TechDays Belgium)
Understanding The MVVM Pattern (TechDays Belgium)
 
Node.js for .NET Developers
Node.js for .NET DevelopersNode.js for .NET Developers
Node.js for .NET Developers
 
JavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform appsJavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform apps
 
Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0Targeting Mobile Platform with MVC 4.0
Targeting Mobile Platform with MVC 4.0
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
 
MVP Mix 2015 Leveraging MVVM on all Platforms
MVP Mix 2015  Leveraging MVVM on all PlatformsMVP Mix 2015  Leveraging MVVM on all Platforms
MVP Mix 2015 Leveraging MVVM on all Platforms
 

More from Emanuele DelBono

More from Emanuele DelBono (13)

The simplest thing that could possibly work
The simplest thing that could possibly workThe simplest thing that could possibly work
The simplest thing that could possibly work
 
Una crescita armoniosa
Una crescita armoniosaUna crescita armoniosa
Una crescita armoniosa
 
A sip of Elixir
A sip of ElixirA sip of Elixir
A sip of Elixir
 
React.js in real world apps.
React.js in real world apps. React.js in real world apps.
React.js in real world apps.
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
From ActiveRecord to EventSourcing
From ActiveRecord to EventSourcingFrom ActiveRecord to EventSourcing
From ActiveRecord to EventSourcing
 
Ruby seen by a C# developer
Ruby seen by a C# developerRuby seen by a C# developer
Ruby seen by a C# developer
 
Ruby loves DDD
Ruby loves DDDRuby loves DDD
Ruby loves DDD
 
Node azure
Node azureNode azure
Node azure
 
Da programmatore a CEO
Da programmatore a CEODa programmatore a CEO
Da programmatore a CEO
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Test driving an MVVM App
Test driving an MVVM AppTest driving an MVVM App
Test driving an MVVM App
 
Mocking
MockingMocking
Mocking
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

An introduction to knockout.js