SlideShare una empresa de Scribd logo
1 de 84
KnockoutJS with
 ASP.NET MVC
    Part 1


   Learn More @ http://www.learnnowonline.com
      Copyright © by Application Developers Training Company
Overview




       Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?
• Getting Started




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?
• Getting Started
• Observables




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings
•   Templating




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings
•   Templating
•   Customizing KnockOutJS


             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
What’s KnockoutJS and why do I
care?




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
What’s KnockoutJS and why do I
care?
KnockoutJS (KO for short) allows:




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
What’s KnockoutJS and why do I
care?
KnockoutJS (KO for short) allows:
• Rich, responsive user interfaces




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
What’s KnockoutJS and why do I
care?
KnockoutJS (KO for short) allows:
• Rich, responsive user interfaces
• Dependency tracking




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
What’s KnockoutJS and why do I
care?
KnockoutJS (KO for short) allows:
• Rich, responsive user interfaces
• Dependency tracking
• Declarative Bindings




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
What’s KnockoutJS and why do I
care?
KnockoutJS (KO for short) allows:
• Rich, responsive user interfaces
• Dependency tracking
• Declarative Bindings
• Self-contained JavaScript library (14Kb
  with gZip!)




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
What’s KnockoutJS and why do I
care?
KnockoutJS (KO for short) allows:
• Rich, responsive user interfaces
• Dependency tracking
• Declarative Bindings
• Self-contained JavaScript library (14Kb
  with gZip!)
• Supports mainstream browsers (IE6+, FF
  2+, Chrome, Safari and others)


           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
What’s KnockoutJS and why do I
care?
KnockoutJS (KO for short) allows:
• Rich, responsive user interfaces
• Dependency tracking
• Declarative Bindings
• Self-contained JavaScript library (14Kb
  with gZip!)
• Supports mainstream browsers (IE6+, FF
  2+, Chrome, Safari and others)
• MVVM for JSON data

           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
What is KnockoutJS




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
What is KnockoutJS
• Declarative Bindings




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
What is KnockoutJS
• Declarative Bindings
• Automatic UI Refresh




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
What is KnockoutJS
• Declarative Bindings
• Automatic UI Refresh
• Dependency Tracking




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
What is KnockoutJS
•   Declarative Bindings
•   Automatic UI Refresh
•   Dependency Tracking
•   Templating




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
What is KnockoutJS
•   Declarative Bindings
•   Automatic UI Refresh
•   Dependency Tracking
•   Templating
•   No Dependencies!




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
What isn’t KnockOutJS




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
What isn’t KnockOutJS
• Not a replacement for jQuery




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
What isn’t KnockOutJS
• Not a replacement for jQuery
• Not a Prototype for JavaScript




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
What isn’t KnockOutJS
• Not a replacement for jQuery
• Not a Prototype for JavaScript

  …
   <head>
     <script type=“text/javascript” src=“jquery.min.js” />
     <script type=“text/javascript” src=“knockout.min.js” />
   </head>
  …




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
3 Core Features of




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
3 Core Features of
1. Observables and dependency tracking




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
3 Core Features of
1. Observables and dependency tracking
2. Declarative bindings




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
3 Core Features of
1. Observables and dependency tracking
2. Declarative bindings
3. Templating




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Model-View-View-Model




      Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company
Model-View-View-Model
MVVM: Design pattern for building user
interfaces




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Model-View-View-Model
MVVM: Design pattern for building user
interfaces
• Model – Data of your application




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Model-View-View-Model
MVVM: Design pattern for building user
interfaces
• Model – Data of your application
• View Model – Entity (field) structure of
  your data




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Model-View-View-Model
MVVM: Design pattern for building user
interfaces
• Model – Data of your application
• View Model – Entity (field) structure of
  your data
• View – UI that represents the View
  Model and the interactions within it


           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview




       Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?
• Getting Started




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?
• Getting Started
• Observables




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings
•   Templating




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings
•   Templating
•   Customizing KnockOutJS


             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Getting Started




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Getting Started
• If using ASP.NET MVC 4




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Getting Started
• If using ASP.NET MVC 4
  • Good news, it’s part of the template!




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Getting Started
• If using ASP.NET MVC 4
  • Good news, it’s part of the template!
  • Start a new MVC 4 project in Visual Studio




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Getting Started
• If using ASP.NET MVC 4
  • Good news, it’s part of the template!
  • Start a new MVC 4 project in Visual Studio
• If using some other technology




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Getting Started
• If using ASP.NET MVC 4
  • Good news, it’s part of the template!
  • Start a new MVC 4 project in Visual Studio
• If using some other technology
  • Download KO from http://knockoutjs.com




            Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Update KO and add
Knockout.Mapping




        Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Update KO and add
Knockout.Mapping
• Knockout.mapping is an plugin to KO




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Update KO and add
Knockout.Mapping
• Knockout.mapping is an plugin to KO
• Need latest version of KO for items like
  $index




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Update KO and add
Knockout.Mapping
• Knockout.mapping is an plugin to KO
• Need latest version of KO for items like
  $index
  • https://github.com/SteveSanderson/knockout/downloads




              Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Update KO and add
Knockout.Mapping
• Knockout.mapping is an plugin to KO
• Need latest version of KO for items like
  $index
  • https://github.com/SteveSanderson/knockout/downloads


  In Visual Studio, open:
  Tools > Library Package Manager > Package Manager Console

  Type:
  Install-Package knockout.mapping




                Learn More @ http://www.learnnowonline.com
                   Copyright © by Application Developers Training Company
Overview




       Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?
• Getting Started




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?
• Getting Started
• Observables




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings
•   Templating




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings
•   Templating
•   Customizing KnockOutJS


             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Observables




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Observables
• One of the 3 cores of KnockoutJS




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Observables
• One of the 3 cores of KnockoutJS
• Allows reading and writing values




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Observables
• One of the 3 cores of KnockoutJS
• Allows reading and writing values
• Allows subscriptions (for notifying of a
  change)




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Observables: Example




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Observables: Example
• View Model in KO is easy, just declare
  your view model like the example
  below




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Observables: Example
• View Model in KO is easy, just declare
  your view model like the example
  below
  …
  var viewModel = {
     productName: ‘Widget’,
     productCat: ‘Other’
  };
  …




                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Observables: Example
• View Model in KO is easy, just declare
  your view model like the example
  below
  …
  var viewModel = {
     productName: ‘Widget’,
     productCat: ‘Other’
  };
  …


  The product is <span data-bind=“text: productName”></span>



                 Learn More @ http://www.learnnowonline.com
                    Copyright © by Application Developers Training Company
Computed Observables




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Computed Observables
• Allows customizations to View Model
  fields




          Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Computed Observables
• Allows customizations to View Model
  fields
  function productsViewModel () {
    this.productName = ko.observable(‘Widget’);
    this.productModel = ko.observable(‘12345’);

      this.productDisplay = ko.computed(function() {
          return this.productName() + “ ( “ + this.productModel ()+ “ ) “;
      }, this);
  }




                    Learn More @ http://www.learnnowonline.com
                        Copyright © by Application Developers Training Company
Computed Observables
• Allows customizations to View Model
  fields
  function productsViewModel () {
    this.productName = ko.observable(‘Widget’);
    this.productModel = ko.observable(‘12345’);

      this.productDisplay = ko.computed(function() {
          return this.productName() + “ ( “ + this.productModel ()+ “ ) “;
      }, this);
  }


  The result is: Widget (12345)



                    Learn More @ http://www.learnnowonline.com
                        Copyright © by Application Developers Training Company
Observable Arrays




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Observable Arrays
• Used for a collection of items




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Observable Arrays
• Used for a collection of items
  var myArray = ko.observableArray ([
     { name: “Windows”, category: “OS” },
     { name: “Office”, category: “Application” }
  ]);




                  Learn More @ http://www.learnnowonline.com
                      Copyright © by Application Developers Training Company
Overview




       Learn More @ http://www.learnnowonline.com
           Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?
• Getting Started




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
• What is KnockOutJS and why do I care?
• Getting Started
• Observables




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings
•   Templating




             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Overview
•   What is KnockOutJS and why do I care?
•   Getting Started
•   Observables
•   Bindings
•   Templating
•   Customizing KnockOutJS


             Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Learn More!




       Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Learn More!
• This is an excerpt from a larger course. Visit
  www.learnnowonline.com for the full details!




           Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company

Más contenido relacionado

La actualidad más candente

Animation And Testing In AngularJS
Animation And Testing In AngularJSAnimation And Testing In AngularJS
Animation And Testing In AngularJS
Edureka!
 
Startup eng-camp 3
Startup eng-camp 3Startup eng-camp 3
Startup eng-camp 3
Jollen Chen
 

La actualidad más candente (11)

Reactive Data Access with Spring Data
Reactive Data Access with Spring DataReactive Data Access with Spring Data
Reactive Data Access with Spring Data
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?
 
Progressive Enhancement & Mobile [Funka 2012]
Progressive Enhancement & Mobile [Funka 2012]Progressive Enhancement & Mobile [Funka 2012]
Progressive Enhancement & Mobile [Funka 2012]
 
(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향
 
Micro-Frontends JSVidCon
Micro-Frontends JSVidConMicro-Frontends JSVidCon
Micro-Frontends JSVidCon
 
The Spirit of Opensource - contribution as a strategy for growth and innova...
The Spirit of Opensource   - contribution as a strategy for growth and innova...The Spirit of Opensource   - contribution as a strategy for growth and innova...
The Spirit of Opensource - contribution as a strategy for growth and innova...
 
Animation And Testing In AngularJS
Animation And Testing In AngularJSAnimation And Testing In AngularJS
Animation And Testing In AngularJS
 
Accelerating Development with Organizational Opinions
Accelerating Development with Organizational OpinionsAccelerating Development with Organizational Opinions
Accelerating Development with Organizational Opinions
 
Book scrum tutorial
Book   scrum tutorialBook   scrum tutorial
Book scrum tutorial
 
Startup eng-camp 3
Startup eng-camp 3Startup eng-camp 3
Startup eng-camp 3
 
[DevDay 2016] The toolkit for an amazing product - Speaker: Sebastian Sussman...
[DevDay 2016] The toolkit for an amazing product - Speaker: Sebastian Sussman...[DevDay 2016] The toolkit for an amazing product - Speaker: Sebastian Sussman...
[DevDay 2016] The toolkit for an amazing product - Speaker: Sebastian Sussman...
 

Similar a KnockOutJS with ASP.NET MVC

Similar a KnockOutJS with ASP.NET MVC (20)

Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
What's new in Silverlight 5
What's new in Silverlight 5What's new in Silverlight 5
What's new in Silverlight 5
 
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
 
.Net branching and flow control
.Net branching and flow control.Net branching and flow control
.Net branching and flow control
 
Bring a Web Page Alive with jQuery
Bring a Web Page Alive with jQueryBring a Web Page Alive with jQuery
Bring a Web Page Alive with jQuery
 
Working with Controllers and Actions in MVC
Working with Controllers and Actions in MVCWorking with Controllers and Actions in MVC
Working with Controllers and Actions in MVC
 
Quick prototyping apps using JS - Ciklum, Vinnitsa
Quick prototyping apps using JS - Ciklum, VinnitsaQuick prototyping apps using JS - Ciklum, Vinnitsa
Quick prototyping apps using JS - Ciklum, Vinnitsa
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
 
Managing site collections
Managing site collectionsManaging site collections
Managing site collections
 
SQL Server: Security
SQL Server: SecuritySQL Server: Security
SQL Server: Security
 
Expression Blend Motion & Interaction Design
Expression Blend Motion & Interaction DesignExpression Blend Motion & Interaction Design
Expression Blend Motion & Interaction Design
 
Getting Started with .NET
Getting Started with .NETGetting Started with .NET
Getting Started with .NET
 
Building a custom column office 365 app - lessons learnt from building the K...
Building a custom column office 365 app - lessons learnt from building  the K...Building a custom column office 365 app - lessons learnt from building  the K...
Building a custom column office 365 app - lessons learnt from building the K...
 
New in the Visual Studio 2012 IDE
New in the Visual Studio 2012 IDENew in the Visual Studio 2012 IDE
New in the Visual Studio 2012 IDE
 
Object oriented techniques
Object oriented techniquesObject oriented techniques
Object oriented techniques
 
Building share point apps with angularjs
Building share point apps with angularjsBuilding share point apps with angularjs
Building share point apps with angularjs
 
Angular JS Training Agenda
Angular JS Training AgendaAngular JS Training Agenda
Angular JS Training Agenda
 
WPF Binding
WPF BindingWPF Binding
WPF Binding
 
GDPR and EA - Commissioning a web site part 7 - Choosing a web site developer
GDPR and EA - Commissioning a web site part 7 - Choosing a web site developerGDPR and EA - Commissioning a web site part 7 - Choosing a web site developer
GDPR and EA - Commissioning a web site part 7 - Choosing a web site developer
 
The jQuery Library
The  jQuery LibraryThe  jQuery Library
The jQuery Library
 

Más de LearnNowOnline

Más de LearnNowOnline (18)

Windows 8: Shapes and Geometries
Windows 8: Shapes and GeometriesWindows 8: Shapes and Geometries
Windows 8: Shapes and Geometries
 
SQL: Permissions and Data Protection
SQL: Permissions and Data ProtectionSQL: Permissions and Data Protection
SQL: Permissions and Data Protection
 
Attributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programmingAttributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programming
 
Asynchronous Programming
Asynchronous ProgrammingAsynchronous Programming
Asynchronous Programming
 
WPF: Working with Data
WPF: Working with DataWPF: Working with Data
WPF: Working with Data
 
A tour of SQL Server
A tour of SQL ServerA tour of SQL Server
A tour of SQL Server
 
Introducing LINQ
Introducing LINQIntroducing LINQ
Introducing LINQ
 
Generics
GenericsGenerics
Generics
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
SharePoint Document Management
SharePoint Document ManagementSharePoint Document Management
SharePoint Document Management
 
SharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPathSharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPath
 
Web API HTTP Pipeline
Web API HTTP PipelineWeb API HTTP Pipeline
Web API HTTP Pipeline
 
Sql 2012 development and programming
Sql 2012  development and programmingSql 2012  development and programming
Sql 2012 development and programming
 
The Entity Data Model
The Entity Data ModelThe Entity Data Model
The Entity Data Model
 
Introducing the Entity Framework
Introducing the Entity FrameworkIntroducing the Entity Framework
Introducing the Entity Framework
 
Creating a User Interface
Creating a User InterfaceCreating a User Interface
Creating a User Interface
 
Using The .NET Framework
Using The .NET FrameworkUsing The .NET Framework
Using The .NET Framework
 
.NET Variables and Data Types
.NET Variables and Data Types.NET Variables and Data Types
.NET Variables and Data Types
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

KnockOutJS with ASP.NET MVC

  • 1. KnockoutJS with ASP.NET MVC Part 1 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 2. Overview Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 3. Overview • What is KnockOutJS and why do I care? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 4. Overview • What is KnockOutJS and why do I care? • Getting Started Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 5. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 6. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 7. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings • Templating Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 8. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings • Templating • Customizing KnockOutJS Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 9. What’s KnockoutJS and why do I care? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 10. What’s KnockoutJS and why do I care? KnockoutJS (KO for short) allows: Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 11. What’s KnockoutJS and why do I care? KnockoutJS (KO for short) allows: • Rich, responsive user interfaces Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 12. What’s KnockoutJS and why do I care? KnockoutJS (KO for short) allows: • Rich, responsive user interfaces • Dependency tracking Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 13. What’s KnockoutJS and why do I care? KnockoutJS (KO for short) allows: • Rich, responsive user interfaces • Dependency tracking • Declarative Bindings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 14. What’s KnockoutJS and why do I care? KnockoutJS (KO for short) allows: • Rich, responsive user interfaces • Dependency tracking • Declarative Bindings • Self-contained JavaScript library (14Kb with gZip!) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 15. What’s KnockoutJS and why do I care? KnockoutJS (KO for short) allows: • Rich, responsive user interfaces • Dependency tracking • Declarative Bindings • Self-contained JavaScript library (14Kb with gZip!) • Supports mainstream browsers (IE6+, FF 2+, Chrome, Safari and others) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 16. What’s KnockoutJS and why do I care? KnockoutJS (KO for short) allows: • Rich, responsive user interfaces • Dependency tracking • Declarative Bindings • Self-contained JavaScript library (14Kb with gZip!) • Supports mainstream browsers (IE6+, FF 2+, Chrome, Safari and others) • MVVM for JSON data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 17. What is KnockoutJS Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 18. What is KnockoutJS • Declarative Bindings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 19. What is KnockoutJS • Declarative Bindings • Automatic UI Refresh Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 20. What is KnockoutJS • Declarative Bindings • Automatic UI Refresh • Dependency Tracking Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 21. What is KnockoutJS • Declarative Bindings • Automatic UI Refresh • Dependency Tracking • Templating Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 22. What is KnockoutJS • Declarative Bindings • Automatic UI Refresh • Dependency Tracking • Templating • No Dependencies! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 23. What isn’t KnockOutJS Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 24. What isn’t KnockOutJS • Not a replacement for jQuery Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 25. What isn’t KnockOutJS • Not a replacement for jQuery • Not a Prototype for JavaScript Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 26. What isn’t KnockOutJS • Not a replacement for jQuery • Not a Prototype for JavaScript … <head> <script type=“text/javascript” src=“jquery.min.js” /> <script type=“text/javascript” src=“knockout.min.js” /> </head> … Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 27. 3 Core Features of Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 28. 3 Core Features of 1. Observables and dependency tracking Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 29. 3 Core Features of 1. Observables and dependency tracking 2. Declarative bindings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 30. 3 Core Features of 1. Observables and dependency tracking 2. Declarative bindings 3. Templating Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 31. Model-View-View-Model Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 32. Model-View-View-Model MVVM: Design pattern for building user interfaces Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 33. Model-View-View-Model MVVM: Design pattern for building user interfaces • Model – Data of your application Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 34. Model-View-View-Model MVVM: Design pattern for building user interfaces • Model – Data of your application • View Model – Entity (field) structure of your data Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 35. Model-View-View-Model MVVM: Design pattern for building user interfaces • Model – Data of your application • View Model – Entity (field) structure of your data • View – UI that represents the View Model and the interactions within it Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 36. Overview Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 37. Overview • What is KnockOutJS and why do I care? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 38. Overview • What is KnockOutJS and why do I care? • Getting Started Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 39. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 40. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 41. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings • Templating Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 42. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings • Templating • Customizing KnockOutJS Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 43. Getting Started Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 44. Getting Started • If using ASP.NET MVC 4 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 45. Getting Started • If using ASP.NET MVC 4 • Good news, it’s part of the template! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 46. Getting Started • If using ASP.NET MVC 4 • Good news, it’s part of the template! • Start a new MVC 4 project in Visual Studio Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 47. Getting Started • If using ASP.NET MVC 4 • Good news, it’s part of the template! • Start a new MVC 4 project in Visual Studio • If using some other technology Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 48. Getting Started • If using ASP.NET MVC 4 • Good news, it’s part of the template! • Start a new MVC 4 project in Visual Studio • If using some other technology • Download KO from http://knockoutjs.com Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 49. Update KO and add Knockout.Mapping Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 50. Update KO and add Knockout.Mapping • Knockout.mapping is an plugin to KO Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 51. Update KO and add Knockout.Mapping • Knockout.mapping is an plugin to KO • Need latest version of KO for items like $index Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 52. Update KO and add Knockout.Mapping • Knockout.mapping is an plugin to KO • Need latest version of KO for items like $index • https://github.com/SteveSanderson/knockout/downloads Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 53. Update KO and add Knockout.Mapping • Knockout.mapping is an plugin to KO • Need latest version of KO for items like $index • https://github.com/SteveSanderson/knockout/downloads In Visual Studio, open: Tools > Library Package Manager > Package Manager Console Type: Install-Package knockout.mapping Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 54. Overview Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 55. Overview • What is KnockOutJS and why do I care? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 56. Overview • What is KnockOutJS and why do I care? • Getting Started Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 57. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 58. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 59. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings • Templating Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 60. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings • Templating • Customizing KnockOutJS Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 61. Observables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 62. Observables • One of the 3 cores of KnockoutJS Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 63. Observables • One of the 3 cores of KnockoutJS • Allows reading and writing values Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 64. Observables • One of the 3 cores of KnockoutJS • Allows reading and writing values • Allows subscriptions (for notifying of a change) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 65. Observables: Example Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 66. Observables: Example • View Model in KO is easy, just declare your view model like the example below Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 67. Observables: Example • View Model in KO is easy, just declare your view model like the example below … var viewModel = { productName: ‘Widget’, productCat: ‘Other’ }; … Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 68. Observables: Example • View Model in KO is easy, just declare your view model like the example below … var viewModel = { productName: ‘Widget’, productCat: ‘Other’ }; … The product is <span data-bind=“text: productName”></span> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 69. Computed Observables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 70. Computed Observables • Allows customizations to View Model fields Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 71. Computed Observables • Allows customizations to View Model fields function productsViewModel () { this.productName = ko.observable(‘Widget’); this.productModel = ko.observable(‘12345’); this.productDisplay = ko.computed(function() { return this.productName() + “ ( “ + this.productModel ()+ “ ) “; }, this); } Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 72. Computed Observables • Allows customizations to View Model fields function productsViewModel () { this.productName = ko.observable(‘Widget’); this.productModel = ko.observable(‘12345’); this.productDisplay = ko.computed(function() { return this.productName() + “ ( “ + this.productModel ()+ “ ) “; }, this); } The result is: Widget (12345) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 73. Observable Arrays Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 74. Observable Arrays • Used for a collection of items Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 75. Observable Arrays • Used for a collection of items var myArray = ko.observableArray ([ { name: “Windows”, category: “OS” }, { name: “Office”, category: “Application” } ]); Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 76. Overview Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 77. Overview • What is KnockOutJS and why do I care? Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 78. Overview • What is KnockOutJS and why do I care? • Getting Started Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 79. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 80. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 81. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings • Templating Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 82. Overview • What is KnockOutJS and why do I care? • Getting Started • Observables • Bindings • Templating • Customizing KnockOutJS Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 83. Learn More! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 84. Learn More! • This is an excerpt from a larger course. Visit www.learnnowonline.com for the full details! Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. DEMO: rest of section\n