SlideShare a Scribd company logo
Boulos Dib
September 15, 2012
MARQUEE SPONSOR
PLATINUM SPONSOR
PLATINUM SPONSOR
PLATINUM SPONSOR
GOLD SPONSORS
SILVER SPONSORS
   Independent Consultant – Napeague Inc.
   First Commercial Personal Computer 1980 – TRS-80 Model III
   First Z80 based product (Protocol Adaptor For Citibank– 1984)
   First Commercial MS-DOS product (Telex/IBM PC, 50 Baud – 1985)
   Started Windows Development using 16-bit Win 3.x
   Used: 8080/Z80, 68xxx, PDP/RSX,VAX-VMS and x86 (C, C++, C#)
   User Group/Meetup Co-Organizer:
     New York Pluralsight Study Group, XAML NYC
   Other interests:
     Windsurfing, Guitar Playing
   Introduction to Knockout & MVVM
   Built-in bindings
   Custom bindings
   Templates
   Simple development pattern.
     MVVM, aka MVVC, sometimes MVC or MVP
   Separation of concerns (Pattern)
     Separates Model and UI
     Separates Behavior and Structure
   Popular with WPF & Silverlight developers.
     Data Binding makes it easy to implement MVVM.
   The 100K foot level view, Web Application
   Models, Controllers and Views

                     Web Application
                                                           DB
       Views                Controllers       Models
        Partial Views              Routes         Services
         Partial Views              Routes          Services
            Partial Views            Routes            Services
           Code & Markup              Code              Code
   The browser level view
   HTML/CSS – JavaScript - JSON

                         Browser

       View              ViewModel              Model
     HTML & CSS           JavaScript            JSON
                  <h1>                 var x;           {a: b }
   Javascript Library to simplify dynamic UIs
    with automatic refresh.

   Core Concepts
     Declarative Bindings
     Dependency Tracking
     Templates
   Extensible
   If using ASP.NET MVC
     NuGet Package Manager


   Download
     knockoutjs
     jQuery
   Observable
   Computed Observable
   Observable Arrays
   Declarative bindings
   Template Support
   Create the Model
     Retrieve Data: usually via Ajax or other form data
     retrieval (API, LocalStorage).
   Create the ViewModel
     Encapsulate UI behavior and data from model.
   Create the View (HTML Markup)
     <label data-bind=“text: name” />
   Bind the ViewModel to the view
     applyBindings(viewModel)
var viewModel = {
        firstName: ko.observable("John"),
        lastName: ko.observable("Doe")
};
ko.applyBindings(viewModel);




First Name: <input type="text“ data-bind="value: firstName"/>
Last Name: <input type="text" data-bind=“value: lastName" />

<span data-bind="text : firstName"></span>
<input type="text" data-bind="value : lastName" />
var vm = {
   quantity: ko.observable(10),
   price: ko.observable(100),
   taxRate: ko.observable(8.75)
};

viewModel = new vm();
viewModel.totalCost = ko.computed(function () {
  return (parseInt("0" + this.quantity(), 10) * this.price()) * this.taxRate();
}, viewModel);

ko.applyBindings(viewModel);
var viewModel = {
    States: ko.observableArray([
    { State: "New York", Cities: ['New York City', 'East Hampton', 'Yonkers'] },
    { State: "New Jersey", Cities: ['Jersey City', 'Hoboken', 'Maplewood'] },
    { State: "Connecticut", Cities: ['Stamford', 'Greenwich'] },
    { State: "Pennsylvania", Cities: ['Philadelphia'] },
]),
    selectedState: ko.observable(),
    selectedCity: ko.observable()
};

viewModel.selectionMade = ko.computed(function () {
    return (this.selectedState() && this.selectedCity());
}, viewModel);
ko.applyBindings(viewModel);
Type      Description
visible   Used to hide or show DOM elements

text      Display text value in a DOM element

html      Display html in a DOM element

css       Add or remove CSS classes from DOM elements

style     Apply specific style to a DOM Element

attr      Set the value of any attribute on a DOM element
binding   Description
foreach   Used for rendering lists based on array bindings.

If        Conditional inclusion of markup and any related binding based on
          truthy condition
Ifnot     Conditional inclusion of markup and any related binding based on a
          falsey condition
with      Creates a new binding context changing what descendent element
          bind to.
binding   Description
click     Add an event handler so a function is invoked when the associated
          DOM element is clicked.
event     Add an event handler than can be bound to any event, such as
          keypress, mouseover or mouseout.
submit    Event handler used when submitting forms.

enable    Used to enable DOM elements only when the parameter value is
          true. Typically used with form elements like input, select, and
          textarea.
disable   Opposite of enable. Used in the same way.
binding           Description
value             Associates a DOM’s element value with a propery on the
                  viewmodel.
hasfocus          Two way binding for setting focus on an element and chekcing
                  whether an element has focus.
checked           This binding is used for checkable controls. Radio button or
                  checkbox.
options           Used to bind the elements of a drop-down list or multi-select list.

selectedOptions Bind to elements that are currently selected. Used with select and
                options bindings.
uniqueName        Gives an element a unique name if it does not already have a name
                  attribute.
// Subscribe
myViewModel.totalCost.subscribe(function(newValue) {
    alert(“Let’s check if we are above our budget" + newValue);
});


// Dispose of subscription
var subscriptionCost =
myViewModel.totalCost.subscribe(function(newValue) {

/* do some work   */

});

// ...then later...
subscriptionCost.dispose();
   Custom Bindings
   Plugins

   TodoMVC
     http://addyosmani.github.com/todomvc/
   Knockbackjs
     http://kmalakoff.github.com/knockback/
   KnockoutMVC
     http://knockoutmvc.com/
   Named Templates
   Anonymous Templates
   Inline
   External
   Register a binding by adding it as a
    subproperty of ko.bindingHandlers.

   Need to supply two functions:
     init
     update


   And then use it with DOM element bindings.
    <div data-bind=“customBindingName: someValue"> </div>
ko.bindingHandlers.customBindingName = {
  init: function (element, valueAccessor, allBindingsAccessor, viewModel) {

          // This will be called when the binding is first applied to an element
          // Set up any initial state, event handlers, etc. here
     },

     update: function (element, valueAccessor, allBindingsAccessor, VM) {
        // This will be called once when the binding is first
        // applied to an element, and again whenever the associated
        // observable changes value.
        // Update the DOM element based on the supplied values here.
       }

};
   Main Site (Steve Sanderson - Author)
     http://knockoutjs.com
   Ryan Niemeyer - Contributor
     http://www.knockmeout.com
   Contact:
     http://blog.boulosdib.com
     @boulosdib
Ad

More Related Content

What's hot (20)

Data binding w Androidzie
Data binding w AndroidzieData binding w Androidzie
Data binding w Androidzie
The Software House
 
MVC on the server and on the client
MVC on the server and on the clientMVC on the server and on the client
MVC on the server and on the client
Sebastiano Armeli
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
Cornel Stefanache
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developers
Kai Koenig
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
Knoldus Inc.
 
From mvc to viper
From mvc to viperFrom mvc to viper
From mvc to viper
Krzysztof Profic
 
Custom AngularJS Directives
Custom AngularJS DirectivesCustom AngularJS Directives
Custom AngularJS Directives
yprodev
 
MVVM Light Toolkit Works Great, Less Complicated
MVVM Light ToolkitWorks Great, Less ComplicatedMVVM Light ToolkitWorks Great, Less Complicated
MVVM Light Toolkit Works Great, Less Complicated
mdc11
 
Backbone js
Backbone jsBackbone js
Backbone js
Rohan Chandane
 
Dmytro Zaitsev Viper: make your mvp cleaner
Dmytro Zaitsev Viper: make your mvp cleanerDmytro Zaitsev Viper: make your mvp cleaner
Dmytro Zaitsev Viper: make your mvp cleaner
Аліна Шепшелей
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
Boyan Mihaylov
 
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
FalafelSoftware
 
Angular Js Basics
Angular Js BasicsAngular Js Basics
Angular Js Basics
أحمد عبد الوهاب
 
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
Inhacking
 
Angular custom directives
Angular custom directivesAngular custom directives
Angular custom directives
Alexe Bogdan
 
Workshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design PatternsWorkshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design Patterns
Visual Engineering
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
Acquisio
 
WPF Fundamentals
WPF FundamentalsWPF Fundamentals
WPF Fundamentals
Our Community Exchange LLC
 
Knockout js
Knockout jsKnockout js
Knockout js
LearningTech
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1
Michał Orman
 
MVC on the server and on the client
MVC on the server and on the clientMVC on the server and on the client
MVC on the server and on the client
Sebastiano Armeli
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developers
Kai Koenig
 
Custom AngularJS Directives
Custom AngularJS DirectivesCustom AngularJS Directives
Custom AngularJS Directives
yprodev
 
MVVM Light Toolkit Works Great, Less Complicated
MVVM Light ToolkitWorks Great, Less ComplicatedMVVM Light ToolkitWorks Great, Less Complicated
MVVM Light Toolkit Works Great, Less Complicated
mdc11
 
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
Building Custom AngularJS Directives - A Step-by-Step Guide - Dan Wahlin | Fa...
FalafelSoftware
 
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
Inhacking
 
Angular custom directives
Angular custom directivesAngular custom directives
Angular custom directives
Alexe Bogdan
 
Workshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design PatternsWorkshop 2: JavaScript Design Patterns
Workshop 2: JavaScript Design Patterns
Visual Engineering
 
Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
Acquisio
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1
Michał Orman
 

Viewers also liked (19)

CETPA Introduction
CETPA IntroductionCETPA Introduction
CETPA Introduction
Vikash Kumar
 
Ape n ükotnes sp-ōle
Ape  n ükotnes sp-ōleApe  n ükotnes sp-ōle
Ape n ükotnes sp-ōle
egilsdo
 
Union of Agricultural Work Committees (UAWC) presentation
Union of Agricultural Work Committees (UAWC) presentationUnion of Agricultural Work Committees (UAWC) presentation
Union of Agricultural Work Committees (UAWC) presentation
Asian People's Fund
 
Cell Tracking Software: What The Offer Is
Cell Tracking Software: What The Offer IsCell Tracking Software: What The Offer Is
Cell Tracking Software: What The Offer Is
hbwmike
 
Lake to Lake 2011 Jay Karen handouts
Lake to Lake 2011 Jay Karen handoutsLake to Lake 2011 Jay Karen handouts
Lake to Lake 2011 Jay Karen handouts
paiiceo
 
Seattle Dev Garage
Seattle Dev GarageSeattle Dev Garage
Seattle Dev Garage
Joshua Birk
 
2013 awards master (website)
2013 awards master (website)2013 awards master (website)
2013 awards master (website)
TLMI
 
Analysis of music video's
Analysis of music video'sAnalysis of music video's
Analysis of music video's
Becca James
 
Draft 2 planning
Draft 2 planningDraft 2 planning
Draft 2 planning
debbie14
 
Reflexio innovacio--1-2012
Reflexio  innovacio--1-2012Reflexio  innovacio--1-2012
Reflexio innovacio--1-2012
ferranmiguelpaco
 
Islam sebagai sebuah sistem agama
Islam sebagai sebuah sistem agamaIslam sebagai sebuah sistem agama
Islam sebagai sebuah sistem agama
Rizali Avenged
 
Corporate Presentation - BMO 2015 Global Metals & Mining Conference
Corporate Presentation - BMO 2015 Global Metals & Mining ConferenceCorporate Presentation - BMO 2015 Global Metals & Mining Conference
Corporate Presentation - BMO 2015 Global Metals & Mining Conference
primero_mining
 
Tugas geoteknik tambang
Tugas geoteknik tambangTugas geoteknik tambang
Tugas geoteknik tambang
Sylvester Saragih
 
Assignment 10 group assignment final draft
Assignment 10 group assignment final draftAssignment 10 group assignment final draft
Assignment 10 group assignment final draft
debbie14
 
New members 11.03.15
New members 11.03.15New members 11.03.15
New members 11.03.15
TLMI
 
Q4 2013 presentation final
Q4 2013 presentation finalQ4 2013 presentation final
Q4 2013 presentation final
primero_mining
 
Random 091108040922-phpapp02
Random 091108040922-phpapp02Random 091108040922-phpapp02
Random 091108040922-phpapp02
Denka Vladimirova
 
Peran k3 dalam eksplorasi tambang bawah laut 2
Peran k3 dalam eksplorasi tambang bawah laut 2Peran k3 dalam eksplorasi tambang bawah laut 2
Peran k3 dalam eksplorasi tambang bawah laut 2
Sylvester Saragih
 
Use grammar with pictures feb 8 2013 (1)
Use grammar with pictures  feb 8 2013 (1)Use grammar with pictures  feb 8 2013 (1)
Use grammar with pictures feb 8 2013 (1)
Telly J Hajny
 
CETPA Introduction
CETPA IntroductionCETPA Introduction
CETPA Introduction
Vikash Kumar
 
Ape n ükotnes sp-ōle
Ape  n ükotnes sp-ōleApe  n ükotnes sp-ōle
Ape n ükotnes sp-ōle
egilsdo
 
Union of Agricultural Work Committees (UAWC) presentation
Union of Agricultural Work Committees (UAWC) presentationUnion of Agricultural Work Committees (UAWC) presentation
Union of Agricultural Work Committees (UAWC) presentation
Asian People's Fund
 
Cell Tracking Software: What The Offer Is
Cell Tracking Software: What The Offer IsCell Tracking Software: What The Offer Is
Cell Tracking Software: What The Offer Is
hbwmike
 
Lake to Lake 2011 Jay Karen handouts
Lake to Lake 2011 Jay Karen handoutsLake to Lake 2011 Jay Karen handouts
Lake to Lake 2011 Jay Karen handouts
paiiceo
 
Seattle Dev Garage
Seattle Dev GarageSeattle Dev Garage
Seattle Dev Garage
Joshua Birk
 
2013 awards master (website)
2013 awards master (website)2013 awards master (website)
2013 awards master (website)
TLMI
 
Analysis of music video's
Analysis of music video'sAnalysis of music video's
Analysis of music video's
Becca James
 
Draft 2 planning
Draft 2 planningDraft 2 planning
Draft 2 planning
debbie14
 
Reflexio innovacio--1-2012
Reflexio  innovacio--1-2012Reflexio  innovacio--1-2012
Reflexio innovacio--1-2012
ferranmiguelpaco
 
Islam sebagai sebuah sistem agama
Islam sebagai sebuah sistem agamaIslam sebagai sebuah sistem agama
Islam sebagai sebuah sistem agama
Rizali Avenged
 
Corporate Presentation - BMO 2015 Global Metals & Mining Conference
Corporate Presentation - BMO 2015 Global Metals & Mining ConferenceCorporate Presentation - BMO 2015 Global Metals & Mining Conference
Corporate Presentation - BMO 2015 Global Metals & Mining Conference
primero_mining
 
Assignment 10 group assignment final draft
Assignment 10 group assignment final draftAssignment 10 group assignment final draft
Assignment 10 group assignment final draft
debbie14
 
New members 11.03.15
New members 11.03.15New members 11.03.15
New members 11.03.15
TLMI
 
Q4 2013 presentation final
Q4 2013 presentation finalQ4 2013 presentation final
Q4 2013 presentation final
primero_mining
 
Random 091108040922-phpapp02
Random 091108040922-phpapp02Random 091108040922-phpapp02
Random 091108040922-phpapp02
Denka Vladimirova
 
Peran k3 dalam eksplorasi tambang bawah laut 2
Peran k3 dalam eksplorasi tambang bawah laut 2Peran k3 dalam eksplorasi tambang bawah laut 2
Peran k3 dalam eksplorasi tambang bawah laut 2
Sylvester Saragih
 
Use grammar with pictures feb 8 2013 (1)
Use grammar with pictures  feb 8 2013 (1)Use grammar with pictures  feb 8 2013 (1)
Use grammar with pictures feb 8 2013 (1)
Telly J Hajny
 
Ad

Similar to Knockoutjs databinding (20)

Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
Flavius-Radu Demian
 
MVVM & Data Binding Library
MVVM & Data Binding Library MVVM & Data Binding Library
MVVM & Data Binding Library
10Clouds
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
 
Knockoutjs
KnockoutjsKnockoutjs
Knockoutjs
Yourcontent YC
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
Ran Wahle
 
The Magic of WPF & MVVM
The Magic of WPF & MVVMThe Magic of WPF & MVVM
The Magic of WPF & MVVM
Abhishek Sur
 
Knockout js session
Knockout js sessionKnockout js session
Knockout js session
Ravinder Mahajan
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
Abhishek Sur
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Barry Gervin
 
Backbonejs
BackbonejsBackbonejs
Backbonejs
Sam Lee
 
Knockout js
Knockout jsKnockout js
Knockout js
LearningTech
 
Creating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-htmlCreating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-html
Ilia Idakiev
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
Ilia Idakiev
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
Roberto Messora
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
sapientindia
 
Google Polymer Introduction
Google Polymer IntroductionGoogle Polymer Introduction
Google Polymer Introduction
David Price
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
michael.labriola
 
Angular Framework ppt for beginners and advanced
Angular Framework ppt for beginners and advancedAngular Framework ppt for beginners and advanced
Angular Framework ppt for beginners and advanced
Preetha Ganapathi
 
KnockoutJS and MVVM
KnockoutJS and MVVMKnockoutJS and MVVM
KnockoutJS and MVVM
Manvendra Singh
 
MVVM & Data Binding Library
MVVM & Data Binding Library MVVM & Data Binding Library
MVVM & Data Binding Library
10Clouds
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
Ran Wahle
 
The Magic of WPF & MVVM
The Magic of WPF & MVVMThe Magic of WPF & MVVM
The Magic of WPF & MVVM
Abhishek Sur
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
Abhishek Sur
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Barry Gervin
 
Backbonejs
BackbonejsBackbonejs
Backbonejs
Sam Lee
 
Creating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-htmlCreating lightweight JS Apps w/ Web Components and lit-html
Creating lightweight JS Apps w/ Web Components and lit-html
Ilia Idakiev
 
Web Components Everywhere
Web Components EverywhereWeb Components Everywhere
Web Components Everywhere
Ilia Idakiev
 
MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!MV* presentation frameworks in Javascript: en garde, pret, allez!
MV* presentation frameworks in Javascript: en garde, pret, allez!
Roberto Messora
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
sapientindia
 
Google Polymer Introduction
Google Polymer IntroductionGoogle Polymer Introduction
Google Polymer Introduction
David Price
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
michael.labriola
 
Angular Framework ppt for beginners and advanced
Angular Framework ppt for beginners and advancedAngular Framework ppt for beginners and advanced
Angular Framework ppt for beginners and advanced
Preetha Ganapathi
 
Ad

Recently uploaded (20)

TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 

Knockoutjs databinding

  • 8. Independent Consultant – Napeague Inc.  First Commercial Personal Computer 1980 – TRS-80 Model III  First Z80 based product (Protocol Adaptor For Citibank– 1984)  First Commercial MS-DOS product (Telex/IBM PC, 50 Baud – 1985)  Started Windows Development using 16-bit Win 3.x  Used: 8080/Z80, 68xxx, PDP/RSX,VAX-VMS and x86 (C, C++, C#)  User Group/Meetup Co-Organizer:  New York Pluralsight Study Group, XAML NYC  Other interests:  Windsurfing, Guitar Playing
  • 9. Introduction to Knockout & MVVM  Built-in bindings  Custom bindings  Templates
  • 10. Simple development pattern.  MVVM, aka MVVC, sometimes MVC or MVP  Separation of concerns (Pattern)  Separates Model and UI  Separates Behavior and Structure  Popular with WPF & Silverlight developers.  Data Binding makes it easy to implement MVVM.
  • 11. The 100K foot level view, Web Application  Models, Controllers and Views Web Application DB Views Controllers Models Partial Views Routes Services Partial Views Routes Services Partial Views Routes Services Code & Markup Code Code
  • 12. The browser level view  HTML/CSS – JavaScript - JSON Browser View ViewModel Model HTML & CSS JavaScript JSON <h1> var x; {a: b }
  • 13. Javascript Library to simplify dynamic UIs with automatic refresh.  Core Concepts  Declarative Bindings  Dependency Tracking  Templates  Extensible
  • 14. If using ASP.NET MVC  NuGet Package Manager  Download  knockoutjs  jQuery
  • 15. Observable  Computed Observable  Observable Arrays  Declarative bindings  Template Support
  • 16. Create the Model  Retrieve Data: usually via Ajax or other form data retrieval (API, LocalStorage).  Create the ViewModel  Encapsulate UI behavior and data from model.  Create the View (HTML Markup)  <label data-bind=“text: name” />  Bind the ViewModel to the view  applyBindings(viewModel)
  • 17. var viewModel = { firstName: ko.observable("John"), lastName: ko.observable("Doe") }; ko.applyBindings(viewModel); First Name: <input type="text“ data-bind="value: firstName"/> Last Name: <input type="text" data-bind=“value: lastName" /> <span data-bind="text : firstName"></span> <input type="text" data-bind="value : lastName" />
  • 18. var vm = { quantity: ko.observable(10), price: ko.observable(100), taxRate: ko.observable(8.75) }; viewModel = new vm(); viewModel.totalCost = ko.computed(function () { return (parseInt("0" + this.quantity(), 10) * this.price()) * this.taxRate(); }, viewModel); ko.applyBindings(viewModel);
  • 19. var viewModel = { States: ko.observableArray([ { State: "New York", Cities: ['New York City', 'East Hampton', 'Yonkers'] }, { State: "New Jersey", Cities: ['Jersey City', 'Hoboken', 'Maplewood'] }, { State: "Connecticut", Cities: ['Stamford', 'Greenwich'] }, { State: "Pennsylvania", Cities: ['Philadelphia'] }, ]), selectedState: ko.observable(), selectedCity: ko.observable() }; viewModel.selectionMade = ko.computed(function () { return (this.selectedState() && this.selectedCity()); }, viewModel); ko.applyBindings(viewModel);
  • 20. Type Description visible Used to hide or show DOM elements text Display text value in a DOM element html Display html in a DOM element css Add or remove CSS classes from DOM elements style Apply specific style to a DOM Element attr Set the value of any attribute on a DOM element
  • 21. binding Description foreach Used for rendering lists based on array bindings. If Conditional inclusion of markup and any related binding based on truthy condition Ifnot Conditional inclusion of markup and any related binding based on a falsey condition with Creates a new binding context changing what descendent element bind to.
  • 22. binding Description click Add an event handler so a function is invoked when the associated DOM element is clicked. event Add an event handler than can be bound to any event, such as keypress, mouseover or mouseout. submit Event handler used when submitting forms. enable Used to enable DOM elements only when the parameter value is true. Typically used with form elements like input, select, and textarea. disable Opposite of enable. Used in the same way.
  • 23. binding Description value Associates a DOM’s element value with a propery on the viewmodel. hasfocus Two way binding for setting focus on an element and chekcing whether an element has focus. checked This binding is used for checkable controls. Radio button or checkbox. options Used to bind the elements of a drop-down list or multi-select list. selectedOptions Bind to elements that are currently selected. Used with select and options bindings. uniqueName Gives an element a unique name if it does not already have a name attribute.
  • 24. // Subscribe myViewModel.totalCost.subscribe(function(newValue) { alert(“Let’s check if we are above our budget" + newValue); }); // Dispose of subscription var subscriptionCost = myViewModel.totalCost.subscribe(function(newValue) { /* do some work */ }); // ...then later... subscriptionCost.dispose();
  • 25. Custom Bindings  Plugins  TodoMVC  http://addyosmani.github.com/todomvc/  Knockbackjs  http://kmalakoff.github.com/knockback/  KnockoutMVC  http://knockoutmvc.com/
  • 26. Named Templates  Anonymous Templates  Inline  External
  • 27. Register a binding by adding it as a subproperty of ko.bindingHandlers.  Need to supply two functions:  init  update  And then use it with DOM element bindings. <div data-bind=“customBindingName: someValue"> </div>
  • 28. ko.bindingHandlers.customBindingName = { init: function (element, valueAccessor, allBindingsAccessor, viewModel) { // This will be called when the binding is first applied to an element // Set up any initial state, event handlers, etc. here }, update: function (element, valueAccessor, allBindingsAccessor, VM) { // This will be called once when the binding is first // applied to an element, and again whenever the associated // observable changes value. // Update the DOM element based on the supplied values here. } };
  • 29. Main Site (Steve Sanderson - Author)  http://knockoutjs.com  Ryan Niemeyer - Contributor  http://www.knockmeout.com
  • 30. Contact:  http://blog.boulosdib.com  @boulosdib