This document provides an overview of JQuery, JQuery Mobile, and how they can be used together. JQuery is a popular JavaScript library that simplifies client-side scripting through DOM handling, animations, events, and AJAX. JQuery Mobile builds on JQuery to provide widgets and interfaces optimized for mobile devices. PhoneGap allows building hybrid mobile apps using HTML5, CSS, and JS that are wrapped in native containers, allowing access to device APIs. JQuery handles DOM and AJAX, JQuery Mobile provides the UI, and PhoneGap wraps the app as native.
Advantages of Hiring UIUX Design Service Providers for Your Business
Quick Intro to JQuery and JQuery Mobile
1. JQuery
+
JQuery
Mobile
Jussi
Pohjolainen
Tampere
University
of
Applied
Sciences
2. Overview
• JQuery
– Most
popular
JavaScript
library
to
simplify
client-‐side
scripBng
– DOM
Handling,
animaBons,
events,
AJAX
– Hides
browser
differences!
• JQuery
UI
– Desktop
widgets,
such
as
date
picker,
dialog,
progress
bar,
tabs…
– Built
on
top
of
JQuery
• JQuery
Mobile
– Mobile
app
framework,
mainly
touch
UI
widgets
– Support
for
all
mobile
operaBng
systems
– Built
on
top
of
JQuery
• Possible
to
mix:
JQuery
(dom
handling)
+
JQuery
Mobile
(UI).
3. PhoneGap?
• PhoneGap
(Adobe)
framework
allows
to
build
hybrid
apps
for
mobile
plaTorms
• Hybrid
apps?
– Web
apps
(HTML5+JS)
that
are
wrapped
inside
of
naBve
WebView
widget
• Benefits
– Can
be
sold
in
app
stores
– Can
access
naBve
APIs
• One
possible
stack
for
building
cross
plaTorm
apps:
– JQuery
for
DOM
and
AJAX
Handling
– JQuery
Mobile
for
User
Interface
– PhoneGap
for
wrapping
the
app
as
naBve
5. Quick
Start
• Download
JQuery
file
(hp://jquery.com/)
– 1.x
– 2.x
• Smaller
and
faster,
but
does
not
support
ie6,
7
or
8.
• Windows
Phone
8
plaTorm
supports
IE10.
• Make
your
(x)html
page
and
reference
to
the
file
in
script
block
• Make
your
code
and
use
JQuery
funcBons!
6. <script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
//<![CDATA[
// When document is ready to be manipulated
jQuery(document).ready( pageReadyToBeManipulated );
function pageReadyToBeManipulated() {
// If link is clicked
jQuery("a").click( linkClick );
}
function linkClick(event) {
alert("Thanks for visiting!");
// Prevent the default action
event.preventDefault();
}
//]]>
</script>
7. Some
Basic
Syntax
• JQuery
can
be
used
in
two
ways:
– JQuery()
– Or
– $()
• $
is
an
alias
to
JQuery()!
$
more
commonly
used
8. <script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
//<![CDATA[
// When document is ready to be manipulated
$(document).ready( pageReadyToBeManipulated );
function pageReadyToBeManipulated() {
// If link is clicked
$("a").click( linkClick );
}
function linkClick(event) {
alert("Thanks for visiting!");
// Prevent the default action
event.preventDefault();
}
//]]>
</script>
10. // EVEN SHORTER SYNTAX, FORGET THE DOCUMENT PARAMETER
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
//<![CDATA[
$().ready(function(){
$("a").click(function(event){
alert("Thanks for visiting!");
event.preventDefault();
});
});
//]]>
</script>
11. Geers
in
the
TradiBonal
Way
• getElementsById
• getElementsByTagName
• getAttribute
12. JQuery
and
Selectors
• Select
all
h1
elements
– $(“h1”)
• Select
the
first
one
– $(“h1”)[0]
• Add
contents
– $(“h1”)[0].innerHTML = “hello!”;
• Lot
of
different
selectors
– http://api.jquery.com/category/selectors/
13. CreaBng
Elements
in
TradiBonal
Way
• createElement
• createTextNode
• setAttribute
• appendChild
• removeChild
18. JQuery
Mobile
• UI
for
all
popular
mobile
device
plaTorms
– hp://jquerymobile.com/
• Built
on
top
of
JQuery
• Themes
can
be
changed
• See
demo:
– hp://view.jquerymobile.com/1.3.2/dist/demos/