SlideShare una empresa de Scribd logo
1 de 22
Knockout.js
Presenter: Ankit Kumar, Mindfire Solutions
Presenter: Ankit Kumar, Mindfire Solutions
Agenda
 Introduction
 Key Concepts
 Introduction to MVVM
 Getting started
 Observables
 Bindings
– Control Flow
– Control over text and appearance
– Working with form fields
Interaction with Server-Side Technology
Demo
Introduction
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 (e.g., changing depending on the user’s
actions or when an external data source changes),
KO can help you implement it more simply and
maintainably
Presenter: Ankit Kumar, Mindfire Solutions
Presenter: Ankit Kumar, Mindfire Solutions
Introduction
History: Steve Sanderson
Open Source
Pure JavaScript library (works with multiple
technology)
Can be added on top of your existing web
application
Compact (13kb approx)
Multiple Browser (IE 6+, Firefox 2+, Chrome, Safari,
others)
Solves: Rich interactivity & dynamic updates
Presenter: Ankit Kumar, Mindfire Solutions
Key Concepts
Declarative Binding: Easily associate DOM
elements with model data using a concise, readable
syntax
Automatic UI refreshes: When your data
model's state changes, your UI updates
automatically
Presenter: Ankit Kumar, Mindfire Solutions
Key Concepts
Declarative Binding: Easily associate DOM
elements with model data using a concise, readable
syntax
Automatic UI refreshes: When your data
model's state changes, your UI updates
automatically
Presenter: Ankit Kumar, Mindfire Solutions
Key Concepts
Dependency Tracking: Implicitly set up chains of
relationships between model data, to transform and
combine it.
We are taking about “Observables”
Templating: Quickly generate sophisticated,
nested UIs as a function of your model data
Presenter: Ankit Kumar, Mindfire Solutions
MVVM (Model View
ViewModel)
Model: objects and operations in your business
domain and is independent of any UI
View: interactive UI representing the state of the
view model. It displays information from the view
model, sends commands to the view model (e.g.
clicks events), and updates whenever the state of
the view model changes.
ViewModel: pure-code representation of the data
and operations on a UI. e.g, for a list editor, view
model would be an object holding a list of items, and
exposing methods to add and remove items
Presenter: Ankit Kumar, Mindfire Solutions
MVVM (Model View
ViewModel)
App Data
Interactive
UI
Data + UI
operation
Presenter: Ankit Kumar, Mindfire Solutions
Getting started
What all we need ???
Knockout.js
And
Jquery (if we need some Jquery animation/UI)
Hello World using Knockout(Demo)
Presenter: Ankit Kumar, Mindfire Solutions
Observables
Knockout provides 2 way binding.
This is achieved using observables.
var myViewModel = {
firstName: ko.observable('Mindfire'),
lastName: ko.observable('Solutions')
};
Read: myViewModel.personName()
Write: myViewModel.PersonName('Ltd')
Presenter: Ankit Kumar, Mindfire Solutions
Computed Observables
Computed Observables are very helpful when you
want to do some operation over observables.
var myViewModel = {
this.firstName: ko.observable('Mindfire'),
this.lastName: ko.observable('Solutions')
this.fullName = ko.computed(function() {
return this.firstName() + " " + this.lastName();
}, this);
};
Now we can use “fullName” to bind values
Presenter: Ankit Kumar, Mindfire Solutions
Observables Array
Helps in detecting and responding to changes of a
collection of things.
var myObservableArray = ko.observableArray();
myObservableArray.push('Some value'); //push some value
var anotherObservableArray = ko.observableArray([
{ name: "Bungle", type: "Bear" },
{ name: "George", type: "Hippo" },
{ name: "Zippy", type: "Unknown" }
]);
Read: myObservableArray().length
MyObservableArray()[0] //gives 1st
element
Presenter: Ankit Kumar, Mindfire Solutions
Observables Array Functions
myObservableArray.push('Some new value') - adds a new item to the
end of array
myObservableArray.pop() - removes the last value from the array and
returns it
myObservableArray.unshift('Some new value') - inserts a new item at
the beginning of the array
myObservableArray.shift() - removes the first value from the array and
returns it
myObservableArray.reverse() - reverses the order of the array
myObservableArray.sort() - sorts the array contents.
Presenter: Ankit Kumar, Mindfire Solutions
Observables Array Functions
myObservableArray.remove(someItem) - removes all values that equal
someItem
myObservableArray.remove(function(item) { return item.age < 18 })
removes all values whose age property is less than 18, and returns
them as an array
myObservableArray.removeAll(['Chad', 132, undefined]) removes all
values that equal 'Chad', 123, or undefined and returns them as an
array
myObservableArray.removeAll() removes all values and returns them
as an array
Presenter: Ankit Kumar, Mindfire Solutions
Bindings
For Controlling Text and Appearance we have
– Visible binding
– Text binding
– Html binding
– Css binding
– Style binding
– Attr binding
Will see these in Demo
Presenter: Ankit Kumar, Mindfire Solutions
Bindings for control flow
For Control flow we have
– foreach binding
– if binding
– ifnot binding
– with binding
Will see these in Demo
Presenter: Ankit Kumar, Mindfire Solutions
Binding Events
Click binding
Event binding
Submit binding
Enable/disable binding
Value binding
HasFocus Binding
Checked Binding
Options binding
Selected binding
Unique binding
Presenter: Ankit Kumar, Mindfire Solutions
Templates
The template binding populates the associated
DOM element with the results of rendering a
template.
– Native templating is the mechanism that
underpins foreach, if, with, and other control flow
bindings
– String-based templating is a way to connect
Knockout to a third-party template engine.
Presenter: Ankit Kumar, Mindfire Solutions
Server Side Interaction
DEMO
Presenter: Ankit Kumar, Mindfire Solutions
Questions ?
Presenter: Ankit Kumar, Mindfire Solutions
Thank You

Más contenido relacionado

Destacado

Knockout js
Knockout jsKnockout js
Knockout jshhassann
 
#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 JSHanoi MagentoMeetup
 
#2 Hanoi Magento Meetup - Part 3: Panel discussion
#2 Hanoi Magento Meetup - Part 3: Panel discussion#2 Hanoi Magento Meetup - Part 3: Panel discussion
#2 Hanoi Magento Meetup - Part 3: Panel discussionHanoi MagentoMeetup
 
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With ContainersHanoi MagentoMeetup
 
Knockout (support slides for presentation)
Knockout (support slides for presentation)Knockout (support slides for presentation)
Knockout (support slides for presentation)Aymeric Gaurat-Apelli
 
#3 Hanoi Magento Meetup - Part 3: Magento Website Optimization
#3 Hanoi Magento Meetup - Part 3: Magento Website Optimization#3 Hanoi Magento Meetup - Part 3: Magento Website Optimization
#3 Hanoi Magento Meetup - Part 3: Magento Website OptimizationHanoi MagentoMeetup
 
Introduction to Knockoutjs
Introduction to KnockoutjsIntroduction to Knockoutjs
Introduction to Knockoutjsjhoguet
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.jsEmanuele DelBono
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentationScott Messinger
 
Knockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingKnockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingUdaya Kumar
 
Download presentation
Download presentationDownload presentation
Download presentationwebhostingguy
 

Destacado (20)

Knockout js
Knockout jsKnockout js
Knockout js
 
Knockout js
Knockout jsKnockout js
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
#2 Hanoi Magento Meetup - Part 2: Knockout JS
 
#2 Hanoi Magento Meetup - Part 3: Panel discussion
#2 Hanoi Magento Meetup - Part 3: Panel discussion#2 Hanoi Magento Meetup - Part 3: Panel discussion
#2 Hanoi Magento Meetup - Part 3: Panel discussion
 
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
#3 Hanoi Magento Meetup - Part 2: Scalable Magento Development With Containers
 
Knockout js (Dennis Haney)
Knockout js (Dennis Haney)Knockout js (Dennis Haney)
Knockout js (Dennis Haney)
 
Knockout js
Knockout jsKnockout js
Knockout js
 
knockout.js
knockout.jsknockout.js
knockout.js
 
Knockout (support slides for presentation)
Knockout (support slides for presentation)Knockout (support slides for presentation)
Knockout (support slides for presentation)
 
#3 Hanoi Magento Meetup - Part 3: Magento Website Optimization
#3 Hanoi Magento Meetup - Part 3: Magento Website Optimization#3 Hanoi Magento Meetup - Part 3: Magento Website Optimization
#3 Hanoi Magento Meetup - Part 3: Magento Website Optimization
 
Introduction to Knockoutjs
Introduction to KnockoutjsIntroduction to Knockoutjs
Introduction to Knockoutjs
 
Knockout.js explained
Knockout.js explainedKnockout.js explained
Knockout.js explained
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
KnockoutJS and MVVM
KnockoutJS and MVVMKnockoutJS and MVVM
KnockoutJS and MVVM
 
Knockout js session
Knockout js sessionKnockout js session
Knockout js session
 
An introduction to knockout.js
An introduction to knockout.jsAn introduction to knockout.js
An introduction to knockout.js
 
Knockout.js presentation
Knockout.js presentationKnockout.js presentation
Knockout.js presentation
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Knockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingKnockout JS Development - a Quick Understanding
Knockout JS Development - a Quick Understanding
 
Download presentation
Download presentationDownload presentation
Download presentation
 

Similar a Knockout.js

Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of SignalsCoding Academy
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteRavi Bhadauria
 
KnockOutjs from Scratch
KnockOutjs from ScratchKnockOutjs from Scratch
KnockOutjs from ScratchUdaya Kumar
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnetrainynovember12
 
Knockoutjs Part 2 Beginners
Knockoutjs Part 2 BeginnersKnockoutjs Part 2 Beginners
Knockoutjs Part 2 BeginnersBhaumik Patel
 
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 jsMindfire Solutions
 
MVC pattern for widgets
MVC pattern for widgetsMVC pattern for widgets
MVC pattern for widgetsBehnam Taraghi
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slidesDavid Barreto
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 
MV(X) architecture patterns
MV(X) architecture patternsMV(X) architecture patterns
MV(X) architecture patternsDmitry Koroliov
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applicationsDivyanshGupta922023
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 

Similar a Knockout.js (20)

Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteMVC Design Pattern in JavaScript by ADMEC Multimedia Institute
MVC Design Pattern in JavaScript by ADMEC Multimedia Institute
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Angularjs 2
Angularjs 2 Angularjs 2
Angularjs 2
 
Angular js
Angular jsAngular js
Angular js
 
KnockOutjs from Scratch
KnockOutjs from ScratchKnockOutjs from Scratch
KnockOutjs from Scratch
 
Model View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In AspnetModel View Presenter (MVP) In Aspnet
Model View Presenter (MVP) In Aspnet
 
Knockoutjs Part 2 Beginners
Knockoutjs Part 2 BeginnersKnockoutjs Part 2 Beginners
Knockoutjs Part 2 Beginners
 
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
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
MVC pattern for widgets
MVC pattern for widgetsMVC pattern for widgets
MVC pattern for widgets
 
Jinal desai .net
Jinal desai .netJinal desai .net
Jinal desai .net
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slides
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
MV(X) architecture patterns
MV(X) architecture patternsMV(X) architecture patterns
MV(X) architecture patterns
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 

Más de Mindfire Solutions (20)

Physician Search and Review
Physician Search and ReviewPhysician Search and Review
Physician Search and Review
 
diet management app
diet management appdiet management app
diet management app
 
Business Technology Solution
Business Technology SolutionBusiness Technology Solution
Business Technology Solution
 
Remote Health Monitoring
Remote Health MonitoringRemote Health Monitoring
Remote Health Monitoring
 
Influencer Marketing Solution
Influencer Marketing SolutionInfluencer Marketing Solution
Influencer Marketing Solution
 
ELMAH
ELMAHELMAH
ELMAH
 
High Availability of Azure Applications
High Availability of Azure ApplicationsHigh Availability of Azure Applications
High Availability of Azure Applications
 
IOT Hands On
IOT Hands OnIOT Hands On
IOT Hands On
 
Glimpse of Loops Vs Set
Glimpse of Loops Vs SetGlimpse of Loops Vs Set
Glimpse of Loops Vs Set
 
Oracle Sql Developer-Getting Started
Oracle Sql Developer-Getting StartedOracle Sql Developer-Getting Started
Oracle Sql Developer-Getting Started
 
Adaptive Layout In iOS 8
Adaptive Layout In iOS 8Adaptive Layout In iOS 8
Adaptive Layout In iOS 8
 
Introduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/MacIntroduction to Auto-layout : iOS/Mac
Introduction to Auto-layout : iOS/Mac
 
LINQPad - utility Tool
LINQPad - utility ToolLINQPad - utility Tool
LINQPad - utility Tool
 
Get started with watch kit development
Get started with watch kit developmentGet started with watch kit development
Get started with watch kit development
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Material Design in Android
Material Design in AndroidMaterial Design in Android
Material Design in Android
 
Introduction to OData
Introduction to ODataIntroduction to OData
Introduction to OData
 
Ext js Part 2- MVC
Ext js Part 2- MVCExt js Part 2- MVC
Ext js Part 2- MVC
 
ExtJs Basic Part-1
ExtJs Basic Part-1ExtJs Basic Part-1
ExtJs Basic Part-1
 
Spring Security Introduction
Spring Security IntroductionSpring Security Introduction
Spring Security Introduction
 

Último

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Último (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

Knockout.js

  • 2. Presenter: Ankit Kumar, Mindfire Solutions Agenda  Introduction  Key Concepts  Introduction to MVVM  Getting started  Observables  Bindings – Control Flow – Control over text and appearance – Working with form fields Interaction with Server-Side Technology Demo
  • 3. Introduction 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 (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and maintainably Presenter: Ankit Kumar, Mindfire Solutions
  • 4. Presenter: Ankit Kumar, Mindfire Solutions Introduction History: Steve Sanderson Open Source Pure JavaScript library (works with multiple technology) Can be added on top of your existing web application Compact (13kb approx) Multiple Browser (IE 6+, Firefox 2+, Chrome, Safari, others) Solves: Rich interactivity & dynamic updates
  • 5. Presenter: Ankit Kumar, Mindfire Solutions Key Concepts Declarative Binding: Easily associate DOM elements with model data using a concise, readable syntax Automatic UI refreshes: When your data model's state changes, your UI updates automatically
  • 6. Presenter: Ankit Kumar, Mindfire Solutions Key Concepts Declarative Binding: Easily associate DOM elements with model data using a concise, readable syntax Automatic UI refreshes: When your data model's state changes, your UI updates automatically
  • 7. Presenter: Ankit Kumar, Mindfire Solutions Key Concepts Dependency Tracking: Implicitly set up chains of relationships between model data, to transform and combine it. We are taking about “Observables” Templating: Quickly generate sophisticated, nested UIs as a function of your model data
  • 8. Presenter: Ankit Kumar, Mindfire Solutions MVVM (Model View ViewModel) Model: objects and operations in your business domain and is independent of any UI View: interactive UI representing the state of the view model. It displays information from the view model, sends commands to the view model (e.g. clicks events), and updates whenever the state of the view model changes. ViewModel: pure-code representation of the data and operations on a UI. e.g, for a list editor, view model would be an object holding a list of items, and exposing methods to add and remove items
  • 9. Presenter: Ankit Kumar, Mindfire Solutions MVVM (Model View ViewModel) App Data Interactive UI Data + UI operation
  • 10. Presenter: Ankit Kumar, Mindfire Solutions Getting started What all we need ??? Knockout.js And Jquery (if we need some Jquery animation/UI) Hello World using Knockout(Demo)
  • 11. Presenter: Ankit Kumar, Mindfire Solutions Observables Knockout provides 2 way binding. This is achieved using observables. var myViewModel = { firstName: ko.observable('Mindfire'), lastName: ko.observable('Solutions') }; Read: myViewModel.personName() Write: myViewModel.PersonName('Ltd')
  • 12. Presenter: Ankit Kumar, Mindfire Solutions Computed Observables Computed Observables are very helpful when you want to do some operation over observables. var myViewModel = { this.firstName: ko.observable('Mindfire'), this.lastName: ko.observable('Solutions') this.fullName = ko.computed(function() { return this.firstName() + " " + this.lastName(); }, this); }; Now we can use “fullName” to bind values
  • 13. Presenter: Ankit Kumar, Mindfire Solutions Observables Array Helps in detecting and responding to changes of a collection of things. var myObservableArray = ko.observableArray(); myObservableArray.push('Some value'); //push some value var anotherObservableArray = ko.observableArray([ { name: "Bungle", type: "Bear" }, { name: "George", type: "Hippo" }, { name: "Zippy", type: "Unknown" } ]); Read: myObservableArray().length MyObservableArray()[0] //gives 1st element
  • 14. Presenter: Ankit Kumar, Mindfire Solutions Observables Array Functions myObservableArray.push('Some new value') - adds a new item to the end of array myObservableArray.pop() - removes the last value from the array and returns it myObservableArray.unshift('Some new value') - inserts a new item at the beginning of the array myObservableArray.shift() - removes the first value from the array and returns it myObservableArray.reverse() - reverses the order of the array myObservableArray.sort() - sorts the array contents.
  • 15. Presenter: Ankit Kumar, Mindfire Solutions Observables Array Functions myObservableArray.remove(someItem) - removes all values that equal someItem myObservableArray.remove(function(item) { return item.age < 18 }) removes all values whose age property is less than 18, and returns them as an array myObservableArray.removeAll(['Chad', 132, undefined]) removes all values that equal 'Chad', 123, or undefined and returns them as an array myObservableArray.removeAll() removes all values and returns them as an array
  • 16. Presenter: Ankit Kumar, Mindfire Solutions Bindings For Controlling Text and Appearance we have – Visible binding – Text binding – Html binding – Css binding – Style binding – Attr binding Will see these in Demo
  • 17. Presenter: Ankit Kumar, Mindfire Solutions Bindings for control flow For Control flow we have – foreach binding – if binding – ifnot binding – with binding Will see these in Demo
  • 18. Presenter: Ankit Kumar, Mindfire Solutions Binding Events Click binding Event binding Submit binding Enable/disable binding Value binding HasFocus Binding Checked Binding Options binding Selected binding Unique binding
  • 19. Presenter: Ankit Kumar, Mindfire Solutions Templates The template binding populates the associated DOM element with the results of rendering a template. – Native templating is the mechanism that underpins foreach, if, with, and other control flow bindings – String-based templating is a way to connect Knockout to a third-party template engine.
  • 20. Presenter: Ankit Kumar, Mindfire Solutions Server Side Interaction DEMO
  • 21. Presenter: Ankit Kumar, Mindfire Solutions Questions ?
  • 22. Presenter: Ankit Kumar, Mindfire Solutions Thank You