SlideShare a Scribd company logo
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

More Related Content

Viewers also liked

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
 

Viewers also liked (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 to 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 to 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
 

More from 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
 

Recently uploaded

Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2DianaGray10
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...Product School
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIES VE
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 

Recently uploaded (20)

Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2UiPath Test Automation using UiPath Test Suite series, part 2
UiPath Test Automation using UiPath Test Suite series, part 2
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
IESVE for Early Stage Design and Planning
IESVE for Early Stage Design and PlanningIESVE for Early Stage Design and Planning
IESVE for Early Stage Design and Planning
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 

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