Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
KnockoutJS TechEd NA 2012
Search
John Papa
July 01, 2012
Technology
3
4.2k
KnockoutJS TechEd NA 2012
John Papa
July 01, 2012
Tweet
Share
More Decks by John Papa
See All by John Papa
Choosing Your JavaScript Framework
johnpapa
1
66
deploying_angular.pdf
johnpapa
0
58
Readable Code
johnpapa
7
2.3k
Building Rich Apps with AngularJS on ASP.NET
johnpapa
6
18k
Gulp and Grunt
johnpapa
20
12k
Angular and WIP: Progressive Saving
johnpapa
3
11k
KnockoutJS and MVVM with JavaScript - TechED 2013
johnpapa
1
730
Single Page Applications with Microsoft ASP.NET
johnpapa
1
380
Single Page Apps
johnpapa
3
14k
Other Decks in Technology
See All in Technology
EM完全に理解した と思ったけど、 やっぱり何も分からなかった話 / EM Night Fukuoka #1
hirutas
0
290
エンジニア候補者向け資料2024.04.24.pdf
macloud
0
3.4k
リテール金融(キャッシュレス・ネット銀行・ネット証券)の競争環境と経済圏
8maki
0
1.6k
令和最新版 Ruby プロファイラ "Pf2" のご紹介
osyoyu
0
140
M&A戦略を支えるデータマネジメント (MIDAS Tech Study #16 GENDA Komiyama)
kommy339
1
120
require(ESM)とECMAScript仕様
uhyo
4
1k
Building a RAG-poweredAI chat appwith Python and VS Code
pamelafox
0
160
ルーターでプレゼンする
puhitaku
1
3.3k
web-application-security
matsuihidetoshi
1
200
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
2.1k
実例で紹介するRAG導入時の知見と精度向上の勘所
yamahiro
5
1.7k
Max out Local LLM in Challenging Environments
sashimimochi
1
130
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
43
12k
Teambox: Starting and Learning
jrom
128
8.4k
Building a Scalable Design System with Sketch
lauravandoore
457
32k
Designing for humans not robots
tammielis
247
25k
Happy Clients
brianwarren
92
6.4k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
Designing with Data
zakiwarfel
96
4.8k
The Straight Up "How To Draw Better" Workshop
denniskardys
228
130k
Building Adaptive Systems
keathley
32
1.9k
The Language of Interfaces
destraynor
151
23k
Code Review Best Practice
trishagee
56
15k
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Transcript
None
With and Without Knockout
UI Patterns Data & Bindings Separation of Concerns Structured JavaScript
6+ 2+ Separates behavior and structure Declarative bindings Observables
data-bind="value: firstName" Declarative Binding ko.observable ko.applyBindings Create an Observable Bind
the ViewModel to the View http://jsfiddle.net/johnpapa/BEzJc/
Source object Push from Source to Target
None
With and Without Knockout Observable
Taylor 110 Taylor 914ce Taylor 914ce Taylor 110
data-bind Declarative Binding product: { id: 1001, model: ko.observable("Taylor 314ce"),
salePrice: ko.observable(1199.95) } ko.applyBindings(data); Source object Bind Source to Target, & Vice Versa
None
With and Without Knockout Observable Computed
computed dependentObservable
ko.computed this this.qty vm observables owner
None
With and Without Knockout Observable Computed ObservableArray
None
var myViewModel = { salesPerson: ko.observable("John"), empNum: ko.observable(39811), products: ko.observableArray([
{ model: "Taylor 314CE", price: 1749, id=321 }, { model: "Martin D40", price: 1899, id=479 } ]) }; <span data-bind="text: products().length"></span> Pre-populating Operating on observableArray
None
With and Without Knockout Observable Computed ObservableArray Built In Bindings
enable value options value optionsText optionsValue Built into Knockout Binding
for element attributes Multiple binding expressions
attr checked click css disable enable event hasfocus html options
optionsText optionsValue selectedOptions style submit text uniqueName value visible text value click disable enable attr Display and state bindings Text and value bindings Bindings for specific attributes visible event Event bindings
None
With and Without Knockout Observable Computed ObservableArray Built In Bindings
Templates
• If truthy condition if • If falsy condition ifnot
• Execute for each item in a list foreach • Shortcut to execute for the object with
template: {name: 'productsTmpl', foreach: lines} Pass the context for the
template with “foreach” productsTmpl
if: lines().length > 0 Any “truthy” expression
with: model text: brand text: name <div> <div data-bind="text: model().brand"></div>
<div data-bind="text: model().name"></div> </div>
None
All Part of the Native Template Engine in Knockout
None
With and Without Knockout Observable Computed ObservableArray Built In Bindings
Templates Custom Binding Handlers
None
function(element, valueAccessor function(element, valueAccessor Runs first time the binding is
evaluated Runs after init and every time one of its observables changes
element, valueAccessor, allBindingsAccessor, viewModel valueAccessor element element, valueAccessor, allBindingsAccessor, viewModel
valueAccessor element element Bound DOM element What is passed to the binding All other bindings on same element The viewmodel
None
With and Without Knockout Observable Computed ObservableArray Built In Bindings
Templates
JavaScript: The Developer Experience (DEV308) JavaScript: The Language (DEV307)
http://www.microsoft.com/visualstudio/en-us http://blogs.msdn.com/b/jasonz/ http://www.facebook.com/visualstudio http://twitter.com/#!/visualstudio Somasegar’s Blog http://blogs.msdn.com/b/somasegar/
http://northamerica.msteched.com www.microsoft.com/learning http://microsoft.com/technet http://microsoft.com/msdn
None
None
None
None