SlideShare uma empresa 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

Mais conteúdo relacionado

Destaque

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
 

Destaque (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
 

Semelhante 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
 

Semelhante 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
 

Mais 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

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
"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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Último (20)

"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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)
 
"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...
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

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