SlideShare uma empresa Scribd logo
1 de 28
Using MVVM on
the web with Ignite
UI & Knockoutjs



                                        NISHANTH ANIL
                             TECHNICAL EVANGELIST
                      nanil@infragistics.com | nnish.com
                          facebook.com/InfragisticsIndia

                                                 @nishanil
Agenda
– Patterns
– What’s MVVM?
– What’s Knockoutjs?
  • Simple MVVM Demo
– What’s Ignite UI?
  • Building Enterprise Dashboard in HTML5/jQuery
    demo
– Comparing Javascript MV* frameworks


                                                @nishanil
Patterns – are guidelines not
              rules!
• UI patterns
  –   Model – View – Controller
  –   Model – View – Presenter
  –   Presentation Model
  –   Model – View – ViewModel


• Why do they exist?
  – Separation of concerns
  – Testability
  – Maintainability


                                  @nishanil
MVVM?

 View    ViewModel      Model
(HTML)               (jsonxml)




                                  @nishanil
MVVM recap – WPF
   –   INotifyPropertyChanged/INotifyCollectionChanged
   –   DataContext
   –   DataBinding
   –   Commanding

Read more:
http://nnish.in/myIGblog




                                                         @nishanil
MVVM on the web?




                   @nishanil
@nishanil
What’s knockoutjs?
– a compact javascript library
– implements the MVVM pattern for Javascript
– rich client-side interactivity
– supports all major browsers



     6+           2+

     http://knockoutjs.com/documentation/browser-support.html



                                                                @nishanil
Key Concepts




               @nishanil
Knockout in 3 steps
– Declarative Binding


– Dependency Tracking using Observable



– Activating knockout




                                         @nishanil
Observables
– Updates UI automatically when the
  ViewModel changes (UI notification)
– Very famous 2 way binding!
– Declare your properties as ko.observable()
– ko.observable() objects are functions, not a
  property!




                                                 @nishanil
Computed Observables
– Computes value based on one more
  dependent observable (for e.g, compute full
  name based on first name & last name)




                                            @nishanil
Declarative Binding
 – It’s all about data-bind attribute in HTML
 – Not native to HTML, but perfectly OK!
 – The binding value can be a single value, variable, or
   literal or almost any valid JavaScript expression.




         Built-in Bindings                     valueUpdate options
value, visible, text,                    change, keyup, keypre
uniqueName, click                        ss, afterkeydown
etc…
Not happy with built-in bindings? – roll your own! (custom bindings)
                                                                       @nishanil
Observable Array
– Tracks which objects are in the array, not the
  state of those objects
– Notifies changes for add & remove
– No notification for item changes! (use
 ko.observable())
Pre-populating ObservableArray




          Binding it



                                              @nishanil
Built-in Bindings
                        Text & Appearance

 visible      text        attr       style         css        html




                      Working with Form Fields


click       disable    submit       value        hasfocu     enable
                                                    s

event      checked      options    selectedOptions         uniqueName



            Or roll your own! Support s custom binding


                                                                      @nishanil
Binding – Control Flow
foreach
                     Foreach example
  if

 ifnot

 with




                                @nishanil
Knockout & jQuery
• Not a jQuery competitor, Knockout solves
  a different problem!
• Will work together!




                                         @nishanil
Knockoutjs Demo




                  @nishanil
Enterprise dashboards using
      HTML5/jQuery?



                         @nishanil
@nishanil
The World’s Most Advanced
  JavaScript & HTML5 UI
       Framework


                        @nishanil
@nishanil
and a lot more… www.igniteui.com
                                   @nishanil
Ignite UI Demo




                 @nishanil
Javascript MV* F/W           Web
                                       Composed                  Plays Nicely
        Framework        UI Bindings              Presentation
                                       Views                     With Others
                                                  Layer
        Backbone.js      ✗             ✗          ✓              ✓
        SproutCore 1.x   ✓             ✓          ✗              ✗
        Sammy.js         ✗             ✗          ✓              ✓
        Spine.js         ✗             ✗          ✓              ✓
        Cappuccino       ✓             ✓          ✗              ✗
        Knockout.js      ✓             ✗          ✓              ✓
        Javascript
                         ✗             ✓          ✓              ✓
        MVC
        Google Web
                         ✗             ✓          ✗              ✗
        Toolkit
        Google
                         ✗             ✓          ✓              ✗
        Closure
        Ember.js         ✓             ✓          ✓              ✓
        Angular.js       ✓             ✗          ✓              ✓
        Batman.js        ✓             ✗          ✓              ✓
Source: http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/
                                                                                @nishanil
Resources
– Ignite UI
   • www.igniteui.com
– Infragistics Community
   • http://www.infragistics.com/community/
– KnockoutJS –
   • learn.knockoutjs.com
   • http://www.knockmeout.net/
– If you are new to Javascript
   •   https://developer.mozilla.org/en-US/docs/JavaScript/Guide
– Javascript MVC Frameworks reviewed
   • http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-
     reviewed/


                                                                   @nishanil
Slides & Samples
• You can download these slides from
  – http://www.slideshare.net/nishanthanil/
• Samples
  – Knockout
    • https://github.com/nishanil/koSamples
  – Ignite UI Grid & Knockoutjs
    • http://www.infragistics.com/products/jquery/sample
      /grid/grid-knockoutjs-integration



                                                     @nishanil
Q&A

@nishanil on twitter
facebook.com/InfragisticsIndia



                                                   NISHANTH ANIL
                                        TECHNICAL EVANGELIST
                                 nanil@infragistics.com | nnish.com

                                                            @nishanil

Mais conteúdo relacionado

Semelhante a Using mvvm on the web using knockoutjs & ignite ui

Infragistics: Getting Started with MVVM in WPF & Silverlight
Infragistics: Getting Started with MVVM in WPF & SilverlightInfragistics: Getting Started with MVVM in WPF & Silverlight
Infragistics: Getting Started with MVVM in WPF & Silverlight
Nish Anil
 
JavaOne 2011 - Going Mobile With Java Based Technologies Today
JavaOne 2011 - Going Mobile With Java Based Technologies TodayJavaOne 2011 - Going Mobile With Java Based Technologies Today
JavaOne 2011 - Going Mobile With Java Based Technologies Today
Wesley Hales
 
Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8
Gill Cleeren
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
dswork
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Fabio Franzini
 

Semelhante a Using mvvm on the web using knockoutjs & ignite ui (20)

Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
 
Infragistics: Getting Started with MVVM in WPF & Silverlight
Infragistics: Getting Started with MVVM in WPF & SilverlightInfragistics: Getting Started with MVVM in WPF & Silverlight
Infragistics: Getting Started with MVVM in WPF & Silverlight
 
JavaOne 2011 - Going Mobile With Java Based Technologies Today
JavaOne 2011 - Going Mobile With Java Based Technologies TodayJavaOne 2011 - Going Mobile With Java Based Technologies Today
JavaOne 2011 - Going Mobile With Java Based Technologies Today
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
A Smooth Transition to HTML5
A Smooth Transition to HTML5A Smooth Transition to HTML5
A Smooth Transition to HTML5
 
Advanced MVVM in Windows 8
Advanced MVVM in Windows 8Advanced MVVM in Windows 8
Advanced MVVM in Windows 8
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
 
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjsCodemotion 2013 - Designing complex applications using html5 and knockoutjs
Codemotion 2013 - Designing complex applications using html5 and knockoutjs
 
JS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJSJS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJS
 
Active Web Development
Active Web DevelopmentActive Web Development
Active Web Development
 
Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)
 
Building assets on the fly with Node.js
Building assets on the fly with Node.jsBuilding assets on the fly with Node.js
Building assets on the fly with Node.js
 
Structure mapping your way to better software
Structure mapping your way to better softwareStructure mapping your way to better software
Structure mapping your way to better software
 
Angular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad indiaAngular 6 Training with project in hyderabad india
Angular 6 Training with project in hyderabad india
 
Angular js gtg-27feb2013
Angular js gtg-27feb2013Angular js gtg-27feb2013
Angular js gtg-27feb2013
 
A Smooth Transition to HTML5 Using MVVM
A Smooth Transition to HTML5 Using MVVMA Smooth Transition to HTML5 Using MVVM
A Smooth Transition to HTML5 Using MVVM
 
Seattle bestpractices2010
Seattle bestpractices2010Seattle bestpractices2010
Seattle bestpractices2010
 
Evaluation and prototyping of an HTML5 Client for iOS devices
Evaluation and prototyping of an HTML5 Client for iOS devicesEvaluation and prototyping of an HTML5 Client for iOS devices
Evaluation and prototyping of an HTML5 Client for iOS devices
 
Kicking Up the Dust with Node JS
Kicking Up the Dust with Node JSKicking Up the Dust with Node JS
Kicking Up the Dust with Node JS
 

Mais de Nish Anil

Building mvvm & single pageapps in js
Building mvvm & single pageapps in jsBuilding mvvm & single pageapps in js
Building mvvm & single pageapps in js
Nish Anil
 

Mais de Nish Anil (7)

[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & Xamarin[MobConf] Go mobile with C#, Visual Studio & Xamarin
[MobConf] Go mobile with C#, Visual Studio & Xamarin
 
[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#[MobConf] Programming wearables in c#
[MobConf] Programming wearables in c#
 
APAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.FormsAPAC Webinar: Say Hello To Xamarin.Forms
APAC Webinar: Say Hello To Xamarin.Forms
 
[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile apps[Bdotnet] Cloud connected mobile apps
[Bdotnet] Cloud connected mobile apps
 
Evolve recap XHackers, Bangalore
Evolve recap XHackers, BangaloreEvolve recap XHackers, Bangalore
Evolve recap XHackers, Bangalore
 
iOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using XamariniOS & Android Dev in C# & Visual Studio using Xamarin
iOS & Android Dev in C# & Visual Studio using Xamarin
 
Building mvvm & single pageapps in js
Building mvvm & single pageapps in jsBuilding mvvm & single pageapps in js
Building mvvm & single pageapps in js
 

Último

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Using mvvm on the web using knockoutjs & ignite ui

  • 1. Using MVVM on the web with Ignite UI & Knockoutjs NISHANTH ANIL TECHNICAL EVANGELIST nanil@infragistics.com | nnish.com facebook.com/InfragisticsIndia @nishanil
  • 2. Agenda – Patterns – What’s MVVM? – What’s Knockoutjs? • Simple MVVM Demo – What’s Ignite UI? • Building Enterprise Dashboard in HTML5/jQuery demo – Comparing Javascript MV* frameworks @nishanil
  • 3. Patterns – are guidelines not rules! • UI patterns – Model – View – Controller – Model – View – Presenter – Presentation Model – Model – View – ViewModel • Why do they exist? – Separation of concerns – Testability – Maintainability @nishanil
  • 4. MVVM? View ViewModel Model (HTML) (jsonxml) @nishanil
  • 5. MVVM recap – WPF – INotifyPropertyChanged/INotifyCollectionChanged – DataContext – DataBinding – Commanding Read more: http://nnish.in/myIGblog @nishanil
  • 6. MVVM on the web? @nishanil
  • 8. What’s knockoutjs? – a compact javascript library – implements the MVVM pattern for Javascript – rich client-side interactivity – supports all major browsers 6+ 2+ http://knockoutjs.com/documentation/browser-support.html @nishanil
  • 9. Key Concepts @nishanil
  • 10. Knockout in 3 steps – Declarative Binding – Dependency Tracking using Observable – Activating knockout @nishanil
  • 11. Observables – Updates UI automatically when the ViewModel changes (UI notification) – Very famous 2 way binding! – Declare your properties as ko.observable() – ko.observable() objects are functions, not a property! @nishanil
  • 12. Computed Observables – Computes value based on one more dependent observable (for e.g, compute full name based on first name & last name) @nishanil
  • 13. Declarative Binding – It’s all about data-bind attribute in HTML – Not native to HTML, but perfectly OK! – The binding value can be a single value, variable, or literal or almost any valid JavaScript expression. Built-in Bindings valueUpdate options value, visible, text, change, keyup, keypre uniqueName, click ss, afterkeydown etc… Not happy with built-in bindings? – roll your own! (custom bindings) @nishanil
  • 14. Observable Array – Tracks which objects are in the array, not the state of those objects – Notifies changes for add & remove – No notification for item changes! (use ko.observable()) Pre-populating ObservableArray Binding it @nishanil
  • 15. Built-in Bindings Text & Appearance visible text attr style css html Working with Form Fields click disable submit value hasfocu enable s event checked options selectedOptions uniqueName Or roll your own! Support s custom binding @nishanil
  • 16. Binding – Control Flow foreach Foreach example if ifnot with @nishanil
  • 17. Knockout & jQuery • Not a jQuery competitor, Knockout solves a different problem! • Will work together! @nishanil
  • 18. Knockoutjs Demo @nishanil
  • 19. Enterprise dashboards using HTML5/jQuery? @nishanil
  • 21. The World’s Most Advanced JavaScript & HTML5 UI Framework @nishanil
  • 23. and a lot more… www.igniteui.com @nishanil
  • 24. Ignite UI Demo @nishanil
  • 25. Javascript MV* F/W Web Composed Plays Nicely Framework UI Bindings Presentation Views With Others Layer Backbone.js ✗ ✗ ✓ ✓ SproutCore 1.x ✓ ✓ ✗ ✗ Sammy.js ✗ ✗ ✓ ✓ Spine.js ✗ ✗ ✓ ✓ Cappuccino ✓ ✓ ✗ ✗ Knockout.js ✓ ✗ ✓ ✓ Javascript ✗ ✓ ✓ ✓ MVC Google Web ✗ ✓ ✗ ✗ Toolkit Google ✗ ✓ ✓ ✗ Closure Ember.js ✓ ✓ ✓ ✓ Angular.js ✓ ✗ ✓ ✓ Batman.js ✓ ✗ ✓ ✓ Source: http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/ @nishanil
  • 26. Resources – Ignite UI • www.igniteui.com – Infragistics Community • http://www.infragistics.com/community/ – KnockoutJS – • learn.knockoutjs.com • http://www.knockmeout.net/ – If you are new to Javascript • https://developer.mozilla.org/en-US/docs/JavaScript/Guide – Javascript MVC Frameworks reviewed • http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks- reviewed/ @nishanil
  • 27. Slides & Samples • You can download these slides from – http://www.slideshare.net/nishanthanil/ • Samples – Knockout • https://github.com/nishanil/koSamples – Ignite UI Grid & Knockoutjs • http://www.infragistics.com/products/jquery/sample /grid/grid-knockoutjs-integration @nishanil
  • 28. Q&A @nishanil on twitter facebook.com/InfragisticsIndia NISHANTH ANIL TECHNICAL EVANGELIST nanil@infragistics.com | nnish.com @nishanil