jax code camp 2010 good morning. iphone dev how to develop for the ios 4

33
Jax Code Camp 2010 Good morning

Post on 20-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Jax Code Camp 2010

Good morning

Page 2: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

iPhone Dev

•How to develop for the iOS 4

Page 3: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

jQuery 1.4 and ASP.NETJax Code Camp 2010

Page 4: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

About Me

•David Fekke

•Software Engineer

•Lender Processing Services

•Fekke L.L.C.

•iPhone, iPad and Android Apps

•ASP.NET and ColdFusion

Page 5: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Douglas Crockford “Good architecture is necessary to give programs enough structure to be able to grow large without collapsing into a puddle of confusion.”

Page 6: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

John Resig“The DOM is a mess!”

Page 7: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

jQuery

•Javascript Framework

•2006

•Included with Visual Studio

•20% of all websites

•31% of top 10,000 websites

Page 8: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Licensing

•FREE

•MIT License

•Included with Visual Studio

•Tell the lawyers to relax

Page 9: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

jQuery features

•Do a lot with very little code

•Chain multiple commands together

•AJAX Library

•UI Library

Page 10: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Sample jQuery

$(“div.myClass”).fadeOut().addClass(“myNewClass”);

Page 11: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Microsoft Support

•Microsoft on JQuery Board

•Supported since Visual Studio 2008 sp1

•Intellisense support

•Libraries come included in certain projects

Page 12: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Getting Started

•Download from jquery.com

•Can use a CDN such as Google

•Include jQuery library in your html

Page 13: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

<script src="scripts/jquery.js" type="text/javascript"></script>

Page 14: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

<script type="text/javascript">

jQuery();</script>

Page 15: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

<script type="text/javascript">

$();</script>

Page 16: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

jQuery plays with others

•$ is an Alias of jQuery

•jQuery.noConflict(); will turn off $ alias

•Must be run in document ready()

Page 17: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Page Load

•onload can be used, but not preferred

•$(document).ready() same as onload

•$() will work as a shortcut

Page 18: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Sizzle Selector Library

•Selector Library now its own project

•Core to how jQuery works

•CSS 1-3 selectors for matching elements

Page 19: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Querying in jQuery

•select any DOM element

•$(document); // Document object

•$(p); // all paragraph elements

•$(tr:nth-child(1)); // first row of each table

•$(p > a); // all anchors inside paragraph tags

Page 20: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Trigger Events

•$(a#home).bind(“click”,fn);

•$(a#home).click(fn);

•$(a#home).live(“click”,fn);

Page 21: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Utility functions

•$.trim(someString);

•$.makeArray(obj);

•$.unique(array)

Page 22: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Traversing

•next(expr)

•previous(expr)

•parents(expr)

•siblings(expr)

•children(expr)

Page 23: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Chaining

•$(‘p’).next().css(‘font’,’Times’).append(‘<br/>’);

Page 24: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Use Each with Wrapped Sets

•$(a) returns array

•var single_item = $(a)[0];

•Each(function(){ //do something })

Page 25: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

AJAX

•jQuery.getJSON();

•jQuery.ajax();

Page 26: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

{"menu": { "id": "file", "value": "File", "popup": { "menuitem": [ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"}, {"value": "Close", "onclick": "CloseDoc()"} ] }}}

Page 27: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

jQuery and .NET•Use REST over SOAP

•Try to use JSON over XML if possible

•WCF can output JSON

•var svc = new Sys.Data.DataService("j.svc")

•ASP.NET MVC can handle JSON actions

Page 28: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Plugins

•jQuery is extensible

•Write your own

•jQuery.fn.mypluginname = fn()

•Huge Ecosystem of Plugins

Page 29: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

New to 1.4

•$().live(“eventType”, fn);

•$().closest(“eventType”, fn);

•$().proxy(fn, context);

Page 30: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Demo

Page 31: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

Resources

•jQuery.com

•http://jqueryui.com

•http://jquery14.com

•http://www.manning.com/bibeault/

Page 32: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

?Questions

?

Page 33: Jax Code Camp 2010 Good morning. iPhone Dev How to develop for the iOS 4

How to Contact me

•davidfekke @ gmail dot com

•twitter @davidfekke

•Blog at http://www.fekke.com/blog/