jQuery Mobile, Backbone.js, and ASP.NET MVC

33
jQuery Mobile, Backbone, and ASP.NET MVC A Framework for Making Mobile Web Applications Tuesday, March 5, 13

description

Websites designed for smart phones are one of the fastest growing segments of the internet. jQuery Mobile makes it easy to create sites for mobile devices, but it is mostly about UI. It doesn’t address the needs of an enterprise application. Things like how to load data from and persist data to the server, how to tie the JavaScript and HTML together, and minimize the amount of data transmitted. In this session I will show how to combine jQuery Mobile with Backbone.js and a ASP.NET Web API back-end. The end result is a website which is fast, efficient, and easy to enhance and maintain.

Transcript of jQuery Mobile, Backbone.js, and ASP.NET MVC

Page 1: jQuery Mobile, Backbone.js, and ASP.NET MVC

jQuery Mobile, Backbone, and ASP.NET MVC

A Framework for Making Mobile Web Applications

Tuesday, March 5, 13

Page 2: jQuery Mobile, Backbone.js, and ASP.NET MVC

Introduction

Tuesday, March 5, 13

Page 3: jQuery Mobile, Backbone.js, and ASP.NET MVC

Who Am I?

• Troy Miles

• Senior Software Engineer w/ 30+ years of experience

• Mobile/Mobile Web

• iOS, Android, & Windows Phone 7

Tuesday, March 5, 13

Page 4: jQuery Mobile, Backbone.js, and ASP.NET MVC

Tuesday, March 5, 13

Page 5: jQuery Mobile, Backbone.js, and ASP.NET MVC

Intermediate PhoneGap

• Learn by doing

• JS best practices, iScroll, Maps, Ajax + more

• Saturday, May 18th - 9 AM to 6 PM

• $99 - lunch & materials included

• http://bit.ly/XlxzYp

• CraveLab - Los Angeles

Tuesday, March 5, 13

Page 6: jQuery Mobile, Backbone.js, and ASP.NET MVC

You May Get Mad At Me

• Sorry, in advance if I insult your favorite: company, device, or personality

• I have nothing against any of these companies

• I will gladly do a project for any of them, for the right price

Tuesday, March 5, 13

Page 7: jQuery Mobile, Backbone.js, and ASP.NET MVC

What we aren’t going to cover

• HTML 5

• Client Side Validation

• SQL Server or other databases

• Security

• Offline

Tuesday, March 5, 13

Page 8: jQuery Mobile, Backbone.js, and ASP.NET MVC

What We Will Cover    • Web Apps. vs Device Apps.

• Components

• Framework

• Why Do It This Way?

• Tools of the Trade

• Tips from the Trenches

• Summary

Tuesday, March 5, 13

Page 9: jQuery Mobile, Backbone.js, and ASP.NET MVC

85% of all US adults now own a mobile

phone

Tuesday, March 5, 13

Page 10: jQuery Mobile, Backbone.js, and ASP.NET MVC

56% of all mobile phone owners in the

US access the internet.

Tuesday, March 5, 13

Page 11: jQuery Mobile, Backbone.js, and ASP.NET MVC

Did you know 80% of customers abandon a mobile site if they have a bad user experience?

Tuesday, March 5, 13

Page 12: jQuery Mobile, Backbone.js, and ASP.NET MVC

Web Apps Device Apps

Can migrate web skills Longer learning curve

One source base Many source bases

Deploy when you want Deployment needs approval

You choose when to update User chooses when to update

No device memory used Uses device memory

Difficult to monetize Monetization is built-in

Restricted device access Full access to device hardware

Slower Faster

Tuesday, March 5, 13

Page 13: jQuery Mobile, Backbone.js, and ASP.NET MVC

Components

• ASP.NET MVC

• jQuery

• jQuery Mobile

• Underscore.js

• Backbone.js

Tuesday, March 5, 13

Page 14: jQuery Mobile, Backbone.js, and ASP.NET MVC

ASP.NET MVCASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC includes many features that enable fast, TDD-friendly development for creating sophisticated applications that use the latest web standards.

Tuesday, March 5, 13

Page 15: jQuery Mobile, Backbone.js, and ASP.NET MVC

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.

Tuesday, March 5, 13

Page 16: jQuery Mobile, Backbone.js, and ASP.NET MVC

A unified, HTML5-based user interface system for all popular mobile device platforms, built on the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily theme-able design. 

Requires jQuery.

Tuesday, March 5, 13

Page 17: jQuery Mobile, Backbone.js, and ASP.NET MVC

Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects. 

Tuesday, March 5, 13

Page 18: jQuery Mobile, Backbone.js, and ASP.NET MVC

Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.

Requires Underscore and jQuery.

Tuesday, March 5, 13

Page 19: jQuery Mobile, Backbone.js, and ASP.NET MVC

The Framework• ASP.NET MVC

• jQuery/jQuery Mobile

• The Kernel

• Backbone

Tuesday, March 5, 13

Page 20: jQuery Mobile, Backbone.js, and ASP.NET MVC

ASP.NET MVC 

• Serves the initial page

• Serves data in a RESTful fashion

Tuesday, March 5, 13

Page 21: jQuery Mobile, Backbone.js, and ASP.NET MVC

jQuery Mobile• Handles the UI

Tuesday, March 5, 13

Page 22: jQuery Mobile, Backbone.js, and ASP.NET MVC

Backbone.js• Handles the data on client

• Models

• Views

• Collections

Tuesday, March 5, 13

Page 23: jQuery Mobile, Backbone.js, and ASP.NET MVC

Models

Tuesday, March 5, 13

Page 24: jQuery Mobile, Backbone.js, and ASP.NET MVC

Views

Tuesday, March 5, 13

Page 25: jQuery Mobile, Backbone.js, and ASP.NET MVC

Collections

Tuesday, March 5, 13

Page 26: jQuery Mobile, Backbone.js, and ASP.NET MVC

Why Do It This Way?

• Best User Experience (think speed)

• Lower Server Utilization

• Easier Maintenance

Tuesday, March 5, 13

Page 27: jQuery Mobile, Backbone.js, and ASP.NET MVC

Tools of the Trade

• Chrome Browser (other webkit browser)

• Fiddler2

Tuesday, March 5, 13

Page 28: jQuery Mobile, Backbone.js, and ASP.NET MVC

7 Tips from the Trenches

• Beware of Browser Madness

• Use an Analog

• Use Unique Ids on Markup

• Reference the active page

• Use the pageinit event not $(document).ready()

• Avoid Sloppy JavaScript

• Always Test on a Device

Tuesday, March 5, 13

Page 29: jQuery Mobile, Backbone.js, and ASP.NET MVC

Next Steps

• Download the source code and play with it

• Minify the code

• Use CDNs for open source code

Tuesday, March 5, 13

Page 30: jQuery Mobile, Backbone.js, and ASP.NET MVC

SummaryjQuery Mobile is an easy to use framework which

enables you to create mobile apps quickly. 

Tuesday, March 5, 13

Page 31: jQuery Mobile, Backbone.js, and ASP.NET MVC

Links

• ASP.NET MVC - http://www.asp.net/

• jQuery - http://jquery.com/

• jQuery Mobile - http://jquerymobile.com/

• Underscore - http://documentcloud.github.com/underscoreBackbone - http://documentcloud.github.com/backbone

• JSLint - http://jslint.com/

Tuesday, March 5, 13

Page 32: jQuery Mobile, Backbone.js, and ASP.NET MVC

BooksjQuery Mobile

Jon ReidSebastopol, CA: O’Reilly Media

Inc., 2011

Master Mobile Web Apps with jQuery Mobile 2nd ed.

Matt DoyleBrighton, UK: Elated

Communications Ltd, 2011

Tuesday, March 5, 13

Page 33: jQuery Mobile, Backbone.js, and ASP.NET MVC

The Source Code is on GitHub at:https://github.com/Rockncoder/

JQMContacts2013

Tuesday, March 5, 13