Another look at Knockout JS By Peter Messenger Senior Developer – Triple Point Technology

Slides:



Advertisements
Similar presentations
SharePoint and Knockout for the REST of Us
Advertisements

What is jQuery Mobile? How to use it? Doncho Minkov Telerik Corporation Technical Trainer.
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Developing HTML5 Application using MVVM pattern Pekka Ylenius.
1 Microsoft Access 2002 Tutorial 9 – Automating Tasks With Macros.
The Web Warrior Guide to Web Design Technologies
Knockoutjs and JQuery The One-Two Punch for Richer MVC 4 Applications Connecticut.NET Developers Group November 13, 2012.
Building HTML and JavaScript Apps with KnockoutJS and MVVM DEV361.
MVVM/MVC in Client-side SPA var subTitle = { value: ‘Single page application approaches and usage’, speaker1: ‘Stanimir Todorov, Product Developer Infragistics’,
Introducing new web content management tools for Priority...
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
Exploring Microsoft® Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Robert Grauer and Maryann Barber Using.
ICS 665 Jesse Abdul. jQuery UI Overview  jQuery UI javascript library Includes all UI component functionality  jQuery UI CSS framework Includes standard.
JQuery. What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library that simplifies HTML document traversing and manipulation event handling.
Fundamentals, DOM, Events, AJAX, UI Doncho Minkov Telerik Corporation
Simon Amrein Consultant Trivadis AG What is ASP.NET 4.0 Ajax Ajax Control Toolkit Microsoft Ajax Content Delivery Network jQuery jQuery Client Templates.
About me I attend the Edina chapter of TechMasters Been a programmer since age 13, sparked by playing video games Currently employed at GMAC as an independent.
Reasonable Sakai Widgets Aaron Zeckoski Gonzalo Silverio Antranig Basman
JQuery CS 268. What is jQuery? From their web site:
Rich Internet Applications 7. Single-page application architecture.
NextGen Technology upgrade – Synerizip - Sandeep Kamble.
PhpXperts What is jQuery Javascript Library Fast and concise Simplifies the interaction between HTML and JavaScript.
SUNY Polytechnic Institute CS 490 – Web Design, AJAX, jQueryAngularJS AngularJS is a client-side JavaScript Framework for adding interactivity to HTML.
Knock the jQuery out! Bartosz
Yahoo! User Interface (YUI) Library Natly Mekdara.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Copyright 2007 Adobe Systems Incorporated. 1 ColdFusion 8 : Advanced AJAX Development Rakshith N Computer Scientist Jan 02, 2008.
Improving e:Vision user interface using Bootstrap and jQuery
Utterly Useless Widget creating your own Chameleon widget...
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
SDC 2013 SPA Made Breezy Tiberiu Covaci Ward Bell, v.p. of technology, IdeaBlade.
Telerik Software Academy ASP.NET Web Forms Telerik Software Academy ASP.NET Web Forms.
PHP Form Introduction Getting User Information Text Input.
Unleash the Power of jQuery Doncho Minkov Telerik Software Academy academy.telerik.com Senior Technical Trainer
Wijmo Troy Taylor. What is Wijmo? -Wijmo is a kit of over 40 UI widgets, optimized for client-side web development. -HTML5 -jQuery -CSS3 -SVG.
Fundamentals, Ajax, Templates, UI Doncho Minkov Telerik Corporation
Unleash the Power of jQuery Learning & Development Team Telerik Software Academy.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Unit 10 – JavaScript Validation Instructor: Brent Presley.
4.01B Authoring Languages and Web Authoring Software 4.01 Examine webpage development and design.
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
Unit 13 –JQuery Basics Instructor: Brent Presley.
Functions.  Assignment #2 is now due on Wednesday, Nov 25 th  (No Quiz)  Go over the midterm  Backtrack and re-cover the question about tracing the.
National Aeronautics and Space Administration TablePress Evaluation & Section 508 Accessible Tables with Visual Editor WP Workshop, 3/19/2014.
Understanding JavaScript and Coding Essentials Lesson 8.
PHP Form Processing * referenced from
Model View ViewModel Architecture. MVVM Architecture components.
05 | Integrating JavaScript and MVC 4 Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Flux & React Web Application Development Mark Repka, Rich McNeary, Steve Mueller.
Web Programming Java Script-Introduction. What is Javascript? JavaScript is a scripting language using for the Web. JavaScript is a programming language.
AngularJS. What is AngularJS  Javascript Framework  MVC  for Rich Web Application Development  by Google.
XP Creating Web Pages with Microsoft Office
MVC 4.0, Knockout.js, Bootstrap and EF6.0 FAST, FLEXIBLE AND RESPONSIVE QUICK TO MARKET WEBSITES.
Section 10.1 Define scripting
Internet Made Easy! Make sure all your information is always up to date and instantly available to all your clients.
Unleash the Power of jQuery
Tutorial 6 Topic: jQuery and jQuery Mobile Li Xu
Fundamentals, DOM, Events, AJAX, UI
Section 10.1 YOU WILL LEARN TO… Define scripting
The Cliff Notes Version
JS301 Week 4 Knockout and Objects.
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
Creating Lightning Fast Apps Using AngularJS
Input CS 422: UI Design and Programming
SEEM4570 Tutorial 5: jQuery + jQuery Mobile
Presentation transcript:

Another look at Knockout JS By Peter Messenger Senior Developer – Triple Point Technology

What is Knockout JS? Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and maintainably.

Knockout JS - Site Developed originally by Steve Sanderson – – Microsoft employee, working in England Open Source Framework Available on Github, Nuget In active development, currently version 3.0 More Information on –

Simple Example Javascript: var myViewModel = {firstName: ‘Peter', lastName: ‘Messenger’}; Html : The name is Javascript : ko.applyBindings(myViewModel); Result: The name is Peter

Why is this important? Based on the MVVM design pattern – MVVM stands for Model, View, ViewModel A model: your application’s stored data. A view model: a pure-code representation of the data and operations on a UI A view: a visible, interactive UI representing the state of the view model. – Keeps the logic and presentation layer separated – Much easier to maintain, less prone to error

Extending Example - Observables Javascript: var myViewModel = {firstName: ko.observable(‘Peter‘), lastName: ko.observable(‘Messenger’)}; Result: Exactly the same as before, but…. If personName changes for any reason, the display will automatically change. Extending myViewModel.firstName.subscribe(function(newValue) { alert("The person's new name is " + newValue); });

Extending Example - Computed Javascript: function Person(firstName,lastName) { this.firstName = ko.observable(firstName); this.lastName = ko.observable(lastName); this.fullName = ko.computed(function() { return this.firstName() + " " + this.lastName(); }, this); } var myViewModel = Person(“Peter”,”Messenger”); Result: Exactly the same as before, but…. Can bind to fullName, and this will change, if first name or last name change

Extending Examples - Arrays Javascript: var myViewModel = {people : ko.observableArray()}; myViewModel.people.push(Person(“Peter”,”Messenger”)); myViewModel.people.push(Person(“John”,”Smith”)); myViewModel.people.push(Person(“Sarah”,”Parker”)); Html: First name Last name

Extending Example - Actions Javascript: function PeopleModel() { var self = this; self.people = ko.observableArray([ Person(“Peter”,”Messenger”), Person(“John”,”Smith”), Person(“Sarah”,”Parker”) ]); self.addPerson = function() { self.people.push(Person(“New Guy”,"New at " + new Date())); }; self.removePerson = function() { self.people.remove(this); }

Extending Example – Actions (cont) Html: People Name at position : Remove Add Example Here $index is used to mark the position in the array $parent allows it to jump back a level, $parent can be nested $parent[2] is parent of parent

Existing Bindings Text and appearance Visible, text, html, css, style, attr Control flow Foreach, if, ifnot, with Forms Click, Event, Submit, Enable, Disable, HasFocus, Checked, Options, SelectedOptions

Building your own bindings Javascript ko.bindingHandlers.yourBindingName = { init: function(element, valueAccessor, allBindings, viewModel, bindingContext) { // 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, allBindings, viewModel, bindingContext) { // 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. } }; Html

Wiring up to services (Jquery) Get $.getJSON("/some/url", function(data) { }) Post var data = /* Your data in JSON format - see below */; $.post("/some/url", data, function(returnedData) { // This callback is executed if the post was successful }) Converting var jsonData = ko.toJSON(viewModel);

More documentation There is extensive documentation on the main site – Interactive tutorials – Live examples – Forum – Easy to integrate with JSON based services As the popularity of knockout has increased, many o the javascript UI frameworks have added knockout extensions.

Added in Version 3.0 Clearer error reporting Custom binding, now extensible Bindings now independent and only refresh when needed Computed variables now only notify when they are changed Performance and bug fixes

Integration – Other Frameworks Kendo UI (Telerik) – JQuery UI – jqWidgets – Wijmo (Component One) – sample=Overview sample=Overview

jQuery UI Examples Accordion AutoComplete Button Dialog Menu

Why do I like it? Once you get the hang of it, it is quite easy and nice to use and debuggable Can develop “single page” websites that are fast and responsive Very lean, much less “post back bloat” than MVC Can have html/javascript separate, easier to style with css

A full website based on Knockout JS

Important Links? Presentation slides on my website and blog – – Main Site: Main Site: – Good Reference Site: