SlideShare a Scribd company logo
KKnnoocckkoouutt ..jj ss 
Hands on introduction 
Ioan Antoniu 
December 10, 2013
WWhhaatt iiss KKnnoocckkoouutt..jjss?? 
• Javascript MVVM library 
• Declarative data binding 
• TTeemmppllaattiinngg 
• Automatic UI refresh 
• Dependency tracking 
• Extensible
BBoottttoomm LLiinnee UUppffrroonntt 
• WWhhaatt iiss KKnnoocckkoouutt 
MMVVVVMM f rfarammeewwoorkr kf ofor rJ Jaavavasscrcirpiptt 
OObbseservrvaabblle eV Vieieww M Mooddeelsls 
DDeeclcalararatitvieve a anndd T Temempplalatetded V Vieiewwss 
EEnnabableless s simimppleler,r ,r ereuusasabblele, ,f rforonntetenndd a anndd c lceleaanneer rc coommmmuunnicicaatitoionn w witihth b baackckeenndd • GGooaall 
SSccrartacthch t hthe es suurfrafacece o of fk knnoocckokouutt
MVVM Pattern 
Consists of three parts 
Model: Defines the datastructure 
ViewModel: Adapts the model for presentation 
View: Presents the data in the UI
Knockout.js with ASP.Net Web API
Knockout.js with ASP.Net Web API
Knockout.js with ASP.Net Web API
Knockout.js with ASP.Net Web API
Model 
serialized as 
HTML 
Model 
serialized as 
Form / 
Query string 
Dictionary 
Must know 
how model 
was 
serialized
Interface is 
now 
consistently 
JSON 
Javascript is 
now 
responsible 
for presenting 
JSON and 
communicati 
ng JSON back 
to server
Server Model JSON Model 
View Model 
View 
MMVVVVMM
Declarative Bindings 
Uses data-binding attribute to bind to model 
Bindings for presentational use: 
visible, text, html, css, style, attr, template 
Bindings for user interface elements 
click, event, submit, enable, disable, value, 
checked, options, selectionOptions, 
uniqueName
Working with Observable Arrays 
Knockout provides helper functions 
push, pop, remove, removeAll, unshift, 
shift, reverse, sort, indexOf, splice, slice 
Supports native JavaScript Array functions 
myObservableArray.push(1); indexof , 
r emove
The View Model 
The View Model consists of observable 
properties, variables and/or functions 
var viewModel = { 
<property> : <observableType>, 
… 
<property> : <variable>, 
<property> : <function> 
}
Templating 
Uses jQuery Template syntax 
Has shorthands for more efficient rendering 
foreach 
Define templates in script tags with 
type = text/html 
id = the name of the template
Extensible 
Possible to create your own bindings 
Possible to change the templating engine
How to create an application? 
1. Import neccessary scripts 
2. Define a model 
3. Define a viewmodel 
4. Apply bindings
DDeemmoo 
• PPrroottoottyyppee 
• BBaabbyy sstteeppss 
OObbsseerrvvaabbllee 
VViieeww mmooddeell 
MMooddeell 
AArrrraayy 
• UUgghh,, wwhheerree’’ss tthhee VViieeww ((llooookk aatt pprroottoottyyppee)) 
VViieeww 
VViieeww AArrrraayy ((cclleeaann uupp eennttrryy sshhoouulldd bbee VViieewwMMooddeell)) 
IIttss aallll ccoonnnneecctteedd 
CCoommppuutteedd ((ssiimmppllee))
Questions? 
Give me feedback so I can get better 
 Write me to iantoniu@pentalog.fr for 
the demo app and resources for this 
presentation, other questions etc...
RReessoouurrcceess 
• WWiillll ppoosstt sslliiddeess // ccooddee 
• hhttttpp::////jjssffiiddddllee..nneett// 
DDeecocommppoossee a a p prorobblelemm u ussiningg t hthisis s asannddbbooxx • hhttttpp::////kknnoocckkoouuttjjss..ccoomm// 
InIntetrearacctitvivee t ututotoriraialsls – – e exxppeeririenencce et htheemm • hhttttpp::////wwwwww..kknnoocckkmmeeoouutt..nneett// 
TToonnss o of fe expxpeerireienncece c caapptutureredd i nin t hthisis b blologg • hhttttpp::////cchhaannnneell99..mmssddnn..ccoomm//EEvveennttss//MMIIXX// 
MMIIXX1111//FFRRMM008 
GGreraeat tv vidideeoo f rforomm e eaarlryly d dayayss o of fK Knnoocckkoouutt • hhttttpp::////cchhaannnneell99..mmssddnn..ccoomm//EEvveennttss//TTeecchh 
DDaayyss//TTeecchhDDaayyss--22001122--BBeellggiiuumm//119999 
RReececenntt v vidideeoo o of fK Knnoockckoouut t+ + W Webeb A Appi i+ + U Uppsshhoot t == A Ammaazizningg!!

More Related Content

PDF
Movable Type 5 : テーマの作成方法
TXT
Trabajo
PDF
IGNITE MySQL - Backups Don't Make Me Money
PPT
Haiku
PDF
Công dụng của phấn hoa mật ong
PDF
Denah umum bendungan tapin
TXT
History frame
PDF
ใบงานสำรวจตนเอง M6
Movable Type 5 : テーマの作成方法
Trabajo
IGNITE MySQL - Backups Don't Make Me Money
Haiku
Công dụng của phấn hoa mật ong
Denah umum bendungan tapin
History frame
ใบงานสำรวจตนเอง M6

Viewers also liked (9)

PPT
Непрерывное инновационное развитие. Введение в обучающиеся организации
PPT
Jaypee greens noida .
DOCX
Analisis pelaksanaan kode etik guru indonesia
PDF
Indian economy
PPT
นำเสนอ เกาหลี
PDF
Sgs Training Academy Brochure 2012
PDF
SGS Leadership and Management Solutions
Непрерывное инновационное развитие. Введение в обучающиеся организации
Jaypee greens noida .
Analisis pelaksanaan kode etik guru indonesia
Indian economy
นำเสนอ เกาหลี
Sgs Training Academy Brochure 2012
SGS Leadership and Management Solutions
Ad

Similar to Knockout.js with ASP.Net Web API (20)

PPTX
Knockout implementing mvvm in java script with knockout
PPT
KnockoutJS and MVVM
PPTX
Fundaments of Knockout js
PDF
Knockoutjs databinding
PDF
Knockout in action
PPTX
PPTX
Building databound JavaScript apps with Knockoutjs
ODP
Introduction to Knockout Js
PPTX
Bringing the light to the client with KnockoutJS
KEY
Sugarcoating your frontend one ViewModel at a time
PDF
Knockout js session
PPTX
MV* presentation frameworks in Javascript: en garde, pret, allez!
KEY
Intro to KnockoutJS
PPTX
MVVM Magic in SharePoint 2010 using Knockoutjs!
PPTX
Introduction to Knockoutjs
PPTX
Knockout js
PPTX
KnockOutjs from Scratch
PPT
Knockout.js
PPTX
Knockout.js
PPTX
Knockout js
Knockout implementing mvvm in java script with knockout
KnockoutJS and MVVM
Fundaments of Knockout js
Knockoutjs databinding
Knockout in action
Building databound JavaScript apps with Knockoutjs
Introduction to Knockout Js
Bringing the light to the client with KnockoutJS
Sugarcoating your frontend one ViewModel at a time
Knockout js session
MV* presentation frameworks in Javascript: en garde, pret, allez!
Intro to KnockoutJS
MVVM Magic in SharePoint 2010 using Knockoutjs!
Introduction to Knockoutjs
Knockout js
KnockOutjs from Scratch
Knockout.js
Knockout.js
Knockout js
Ad

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
cuic standard and advanced reporting.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
NewMind AI Weekly Chronicles - August'25 Week I
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Review of recent advances in non-invasive hemoglobin estimation
20250228 LYD VKU AI Blended-Learning.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
cuic standard and advanced reporting.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
sap open course for s4hana steps from ECC to s4
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
The AUB Centre for AI in Media Proposal.docx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Programs and apps: productivity, graphics, security and other tools
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Knockout.js with ASP.Net Web API

  • 1. KKnnoocckkoouutt ..jj ss Hands on introduction Ioan Antoniu December 10, 2013
  • 2. WWhhaatt iiss KKnnoocckkoouutt..jjss?? • Javascript MVVM library • Declarative data binding • TTeemmppllaattiinngg • Automatic UI refresh • Dependency tracking • Extensible
  • 3. BBoottttoomm LLiinnee UUppffrroonntt • WWhhaatt iiss KKnnoocckkoouutt MMVVVVMM f rfarammeewwoorkr kf ofor rJ Jaavavasscrcirpiptt OObbseservrvaabblle eV Vieieww M Mooddeelsls DDeeclcalararatitvieve a anndd T Temempplalatetded V Vieiewwss EEnnabableless s simimppleler,r ,r ereuusasabblele, ,f rforonntetenndd a anndd c lceleaanneer rc coommmmuunnicicaatitoionn w witihth b baackckeenndd • GGooaall SSccrartacthch t hthe es suurfrafacece o of fk knnoocckokouutt
  • 4. MVVM Pattern Consists of three parts Model: Defines the datastructure ViewModel: Adapts the model for presentation View: Presents the data in the UI
  • 9. Model serialized as HTML Model serialized as Form / Query string Dictionary Must know how model was serialized
  • 10. Interface is now consistently JSON Javascript is now responsible for presenting JSON and communicati ng JSON back to server
  • 11. Server Model JSON Model View Model View MMVVVVMM
  • 12. Declarative Bindings Uses data-binding attribute to bind to model Bindings for presentational use: visible, text, html, css, style, attr, template Bindings for user interface elements click, event, submit, enable, disable, value, checked, options, selectionOptions, uniqueName
  • 13. Working with Observable Arrays Knockout provides helper functions push, pop, remove, removeAll, unshift, shift, reverse, sort, indexOf, splice, slice Supports native JavaScript Array functions myObservableArray.push(1); indexof , r emove
  • 14. The View Model The View Model consists of observable properties, variables and/or functions var viewModel = { <property> : <observableType>, … <property> : <variable>, <property> : <function> }
  • 15. Templating Uses jQuery Template syntax Has shorthands for more efficient rendering foreach Define templates in script tags with type = text/html id = the name of the template
  • 16. Extensible Possible to create your own bindings Possible to change the templating engine
  • 17. How to create an application? 1. Import neccessary scripts 2. Define a model 3. Define a viewmodel 4. Apply bindings
  • 18. DDeemmoo • PPrroottoottyyppee • BBaabbyy sstteeppss OObbsseerrvvaabbllee VViieeww mmooddeell MMooddeell AArrrraayy • UUgghh,, wwhheerree’’ss tthhee VViieeww ((llooookk aatt pprroottoottyyppee)) VViieeww VViieeww AArrrraayy ((cclleeaann uupp eennttrryy sshhoouulldd bbee VViieewwMMooddeell)) IIttss aallll ccoonnnneecctteedd CCoommppuutteedd ((ssiimmppllee))
  • 19. Questions? Give me feedback so I can get better  Write me to iantoniu@pentalog.fr for the demo app and resources for this presentation, other questions etc...
  • 20. RReessoouurrcceess • WWiillll ppoosstt sslliiddeess // ccooddee • hhttttpp::////jjssffiiddddllee..nneett// DDeecocommppoossee a a p prorobblelemm u ussiningg t hthisis s asannddbbooxx • hhttttpp::////kknnoocckkoouuttjjss..ccoomm// InIntetrearacctitvivee t ututotoriraialsls – – e exxppeeririenencce et htheemm • hhttttpp::////wwwwww..kknnoocckkmmeeoouutt..nneett// TToonnss o of fe expxpeerireienncece c caapptutureredd i nin t hthisis b blologg • hhttttpp::////cchhaannnneell99..mmssddnn..ccoomm//EEvveennttss//MMIIXX// MMIIXX1111//FFRRMM008 GGreraeat tv vidideeoo f rforomm e eaarlryly d dayayss o of fK Knnoocckkoouutt • hhttttpp::////cchhaannnneell99..mmssddnn..ccoomm//EEvveennttss//TTeecchh DDaayyss//TTeecchhDDaayyss--22001122--BBeellggiiuumm//119999 RReececenntt v vidideeoo o of fK Knnoockckoouut t+ + W Webeb A Appi i+ + U Uppsshhoot t == A Ammaazizningg!!