SlideShare a Scribd company logo
1 of 8
Download to read offline
6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios
spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 1/8
SpyreStudios - Design and Development Magazine
Freebies
Archives
Contact
Advertise
type keywords and hit enter...
Beginner’s Tutorial Coding Web Apps with jQuery Mobile
TweetTweet
24
Contentcomments
advertise hereadvertise here
The whole jQuery library has grown tremendously in the past couple of years. With open resources such as Git and
Github web developers have been creating plugins for even richer effects. Some of the team members had a great idea
to port this code over to a mobile platform.
6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios
spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 2/8
In this guide it is my goal to introduce you into the jQuery Mobile platform. There is a lot of material to cover so we
likely won’t hit everything. But fortunately the team has made development super easy and streamlined with fantastic
documentation. Check out the website and fairly active developer’s forum for more in-depth answers.
A Basic Template
So getting started we should look at an example HTML template used for any standard jQuery Mobile application.
When I talk about a jQM app this doesn’t necessarily mean you need to include user interaction and account signups
and a database.
But I do think jQuery Mobile isn’t exactly for building websites as much as smaller web apps. The browser market has
been finicky in the past, but now we’ve reached a point where the majority do support jQuery Mobile and these apps
can be rapidly developed.
6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios
spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 3/8
Take for example my demo code below. This will output a completely empty page with a simple title and includes the 3
external documents we need for any jQM app. These include the latest JavaScript version of jQuery & jQuery Mobile,
along with the default CSS styles for jQM.
View the demo
Of course this is just a very basic example to get us started. The same semantics still apply where you should add all
your page content within the HTML body tags. But jQuery Mobile will actually let you code multiple app pages into a
single HTML file. This concept is a bit confusing at first so let’s break it down.
You may want to save the template above into a new index.html file. Now within this one file we can use data-roles to
create a couple page elements. When your app first loads the top page will behave as your home or index. Then you
would link between these pages by targeting the ID attribute. The page anatomy section gives you an overview of the
additional elements you may add such as forms, inputs, headers, lists, or even a footer toolbar area.
Linking Between Pages
Below I have included some more example code demonstrating page links. You can add this into the body section of
your own app, or modify the content a bit to your liking. What’s important here is the unique ID for for each container
element and how the anchor links point to a new page.
1 <!DOCTYPEhtml>
2 <html>
3 <head>
4 <title>StandardjQMTemplate</title>
5 <linkrel="stylesheet"href="http://code.jquery.com/mobile/1.0b1/jquery.mobile
6 <scripttype="text/javascript"src="http://code.jquery.com/jquery-1.6.4.min.js
7 <scripttype="text/javascript"src="http://code.jquery.com/mobile/1.0rc2/jquer
8 </head>
9
10 <body>
11
12 </body>
13 </html>
1 <divdata-role="page"id="home">
2 <divdata-role="header">
3 <h1>Hereistheindexpage.</h1>
4 </div>
5
6 <divdata-role="content">
7 <p><center>Belowyoumaytransitiontoourotherpages.</center></p>
8
9 <ahref="#about"data-role="button"data-inline="true">AboutMe</a>
10 </div>
11 </div>
12
13 <divdata-role="page"id="about">
14 <divdata-role="header">
15 <h1>AboutUs</h1>
16 </div>
17
18 <divdata-role="content">
6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios
spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 4/8
View the demo
On each of the anchor links I’m taking advantage of a few more HTML data-attributes. data-role is used to change the
link style from plain text into a rounded button. Similarly the inline attribute makes the button appear as a smaller limited-
width box. Otherwise we have links which span the entirety of the page and just look terrible!
On the About page I added a link with data-rel=”back” which you should familiarize yourself with. jQM does support
browser history and you can use this attribute to simulate a back button at will. I did set the href value same as the home
ID, but we could have used href=”#pork” and still gotten back to the previous view. Only because in this scenario
data-rel overrides the href attribute no matter what value we put in.
Mobile Page Structures
After you begin to see how mobile apps are put together jQM appears more like a framework than simply a JavaScript
library. And within this framework we must work with different rules compared to a regular web design. One such issue
pertains to default page views how different mobile browsers will render the same code.
The meta viewport tag can be added into your header to force all mobile browsers to render page zoom at 100%. This
is a bigger problem with software such as Mobile Safari, as each website is purposefully scaled down to fit within the
screen resolution. But adding the following tag into your header will reset this value and always keep your pages focused
at the right size.
The best part about this method is that you are able to customize how users experience your app. For example in my
code above the user can still re-size the zoom at will if they don’t like our 100% setting. By adding user-scalable=no
to the list of commands your app will be locked into the scope and overrides default browser settings.
19 <ahref="#home"data-rel="back"data-role="button"data-inline="true">&laqu
20 </div>
21 </div>
1 <metaname="viewport"content="width=device-width,initial-scale=1.0,minimum-s
6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios
spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 5/8
Images are also a bit difficult to manage. Ultimately as the web designer it is your choice on how to handle image sizes. I
recommend keeping things below a 450px width but experiment to see what looks best. By default visitors will be able
to swipe over and down to get the whole view if your image exceeds the screen size. But you can set full 100% width
for iOS devices using some real basic CSS styles to fix this for most of your traffic.
Remove the Loading Message
One other annoyance is the modal box which appears each time you transition to another page. jQuery Mobile has this
running by default which ironically may not be the most effective choice. This appears whether you are loading pages
from within the same file or external individual files.
To remove this we need to call upon a bit of JavaScript. This relies on jQuery commands but needs to be implemented
before the jQuery Mobile library is initialized. Thus you’ll want to include this code in the middle of these 2 docs in your
header area. I just added everything inline and you can check out my demo below.
View the demo
The mobileinit method is run immediately after jQuery Mobile has finished loading. We are binding an event handler to
that method and calling our own function as a response. The setting for $.mobile.loadingMessageis generally a
string of text which appears in the loading message dialog between pages. But when set to false the whole feature is
disabled immediately! You can read more about global configuration and other jQM settings from their online docs.
Conclusion
In this brief tutorial we have covered the very basics of a jQuery Mobile application. I’ve exposed you to a basic
template and the required elements for any standard page, along with some more intermediate-to-advanced level
configuration stuff. After this guide you should feel a lot more comfortable toying around with the Mobile library and
exploring their online documentation.
If you have built your own mobile template or design we’d love to check it out. The current 1.0 release is stable and will
continue with bug fixes as time progresses. Let us know your thoughts in the discussion area below along with any
questions or complaints you have.
1 <scripttype="text/javascript"src="http://code.jquery.com/jquery-1.6.4.min.js"
2 <scripttype="text/javascript">
3 $(document).bind("mobileinit",function(){
4 $.mobile.loadingMessage=false;
5 });
6 </script>
7 <scripttype="text/javascript"src="http://code.jquery.com/mobile/1.0rc2/jquer
8 </head>
6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios
spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 6/8
advertise hereadvertise here
About the author:
Jake is a social media enthusiast and an Internet entrepreneur. He frequently writes articles involving new-age design
concepts and freelance management skills. You can find him in Google or follow his tweets @jakerocheleau
Related Entries:
How to Style iOS Sliding Checkboxes with jQuery
Code a Dynamic Questions & Answers FAQ Page with jQuery
How To Build an Alphabetical Page Index using jQuery
Building a Live Textarea Character Count Limit with CSS3 and jQuery
Coding an Image Thumbnail Hover Magnify Effect with jQuery
Comments:
6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios
spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 7/8
Advertise Here
Reason:
Content blocked
by your
organization
This
Websense
category is
Options: Click more
information to
learn more about
your access
policy.
Popular Articles and Resources (view archives)
6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios
spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 8/8
advertise hereadvertise here
Copyright 2007-2011. All rights reserved. Privacy Policy

More Related Content

More from Daniel Downs

Module 10search engine optimization
Module 10search engine optimizationModule 10search engine optimization
Module 10search engine optimizationDaniel Downs
 
Ipad quick-reference-2
Ipad quick-reference-2Ipad quick-reference-2
Ipad quick-reference-2Daniel Downs
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Daniel Downs
 
Jquery template 1 3 pages
Jquery template 1 3 pagesJquery template 1 3 pages
Jquery template 1 3 pagesDaniel Downs
 
Module6 htmlcss helpfulcodeandwebsites
Module6 htmlcss helpfulcodeandwebsitesModule6 htmlcss helpfulcodeandwebsites
Module6 htmlcss helpfulcodeandwebsitesDaniel Downs
 
Module 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel DownsModule 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel DownsDaniel Downs
 
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington MaModule 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington MaDaniel Downs
 
Module 2 lexington minuteman web development basic layout template
Module 2  lexington minuteman web development basic layout templateModule 2  lexington minuteman web development basic layout template
Module 2 lexington minuteman web development basic layout templateDaniel Downs
 
Module 1 Web design & Development Lexington Minuteman
Module 1 Web design & Development Lexington MinutemanModule 1 Web design & Development Lexington Minuteman
Module 1 Web design & Development Lexington MinutemanDaniel Downs
 
App research project
App research projectApp research project
App research projectDaniel Downs
 
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...Daniel Downs
 
Blogger custom domain on go daddy blogger widgets
Blogger custom domain on go daddy   blogger widgetsBlogger custom domain on go daddy   blogger widgets
Blogger custom domain on go daddy blogger widgetsDaniel Downs
 
Outline for action research prospectus
Outline for action research prospectusOutline for action research prospectus
Outline for action research prospectusDaniel Downs
 
You have decided to go off on your own as a freelance webdesigner
You have decided to go off on your own as a freelance webdesignerYou have decided to go off on your own as a freelance webdesigner
You have decided to go off on your own as a freelance webdesignerDaniel Downs
 
Making a basicappinflash (1)
Making a basicappinflash (1)Making a basicappinflash (1)
Making a basicappinflash (1)Daniel Downs
 
Daniel Downs Technology Portfolio Final May 2013 final (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)Daniel Downs Technology Portfolio Final May 2013 final (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)Daniel Downs
 
Web design 1& 2 lesson outline
Web design 1& 2 lesson outlineWeb design 1& 2 lesson outline
Web design 1& 2 lesson outlineDaniel Downs
 
You are part of an international news team reporting from a foreign country
You are part of an international news team reporting from a foreign countryYou are part of an international news team reporting from a foreign country
You are part of an international news team reporting from a foreign countryDaniel Downs
 
Marketing plan powerpoint
Marketing plan powerpointMarketing plan powerpoint
Marketing plan powerpointDaniel Downs
 
Final screen castfinalweb12
Final screen castfinalweb12Final screen castfinalweb12
Final screen castfinalweb12Daniel Downs
 

More from Daniel Downs (20)

Module 10search engine optimization
Module 10search engine optimizationModule 10search engine optimization
Module 10search engine optimization
 
Ipad quick-reference-2
Ipad quick-reference-2Ipad quick-reference-2
Ipad quick-reference-2
 
Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.Index of jquery template 2 Minuteman Summer Web Dev.
Index of jquery template 2 Minuteman Summer Web Dev.
 
Jquery template 1 3 pages
Jquery template 1 3 pagesJquery template 1 3 pages
Jquery template 1 3 pages
 
Module6 htmlcss helpfulcodeandwebsites
Module6 htmlcss helpfulcodeandwebsitesModule6 htmlcss helpfulcodeandwebsites
Module6 htmlcss helpfulcodeandwebsites
 
Module 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel DownsModule 4 Minuteman Lexington Web Design Daniel Downs
Module 4 Minuteman Lexington Web Design Daniel Downs
 
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington MaModule 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
Module 3 Progress Codes Web Design Daniel Downs Minuteman Lexington Ma
 
Module 2 lexington minuteman web development basic layout template
Module 2  lexington minuteman web development basic layout templateModule 2  lexington minuteman web development basic layout template
Module 2 lexington minuteman web development basic layout template
 
Module 1 Web design & Development Lexington Minuteman
Module 1 Web design & Development Lexington MinutemanModule 1 Web design & Development Lexington Minuteman
Module 1 Web design & Development Lexington Minuteman
 
App research project
App research projectApp research project
App research project
 
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
Daniel Downs: Student Experiences In A Project Based Learning Technology Curr...
 
Blogger custom domain on go daddy blogger widgets
Blogger custom domain on go daddy   blogger widgetsBlogger custom domain on go daddy   blogger widgets
Blogger custom domain on go daddy blogger widgets
 
Outline for action research prospectus
Outline for action research prospectusOutline for action research prospectus
Outline for action research prospectus
 
You have decided to go off on your own as a freelance webdesigner
You have decided to go off on your own as a freelance webdesignerYou have decided to go off on your own as a freelance webdesigner
You have decided to go off on your own as a freelance webdesigner
 
Making a basicappinflash (1)
Making a basicappinflash (1)Making a basicappinflash (1)
Making a basicappinflash (1)
 
Daniel Downs Technology Portfolio Final May 2013 final (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)Daniel Downs Technology Portfolio Final May 2013 final (1)
Daniel Downs Technology Portfolio Final May 2013 final (1)
 
Web design 1& 2 lesson outline
Web design 1& 2 lesson outlineWeb design 1& 2 lesson outline
Web design 1& 2 lesson outline
 
You are part of an international news team reporting from a foreign country
You are part of an international news team reporting from a foreign countryYou are part of an international news team reporting from a foreign country
You are part of an international news team reporting from a foreign country
 
Marketing plan powerpoint
Marketing plan powerpointMarketing plan powerpoint
Marketing plan powerpoint
 
Final screen castfinalweb12
Final screen castfinalweb12Final screen castfinalweb12
Final screen castfinalweb12
 

Recently uploaded

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 

Recently uploaded (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 

Beginner’s tutorial coding web apps with j query mobile spyrestudios

  • 1. 6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 1/8 SpyreStudios - Design and Development Magazine Freebies Archives Contact Advertise type keywords and hit enter... Beginner’s Tutorial Coding Web Apps with jQuery Mobile TweetTweet 24 Contentcomments advertise hereadvertise here The whole jQuery library has grown tremendously in the past couple of years. With open resources such as Git and Github web developers have been creating plugins for even richer effects. Some of the team members had a great idea to port this code over to a mobile platform.
  • 2. 6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 2/8 In this guide it is my goal to introduce you into the jQuery Mobile platform. There is a lot of material to cover so we likely won’t hit everything. But fortunately the team has made development super easy and streamlined with fantastic documentation. Check out the website and fairly active developer’s forum for more in-depth answers. A Basic Template So getting started we should look at an example HTML template used for any standard jQuery Mobile application. When I talk about a jQM app this doesn’t necessarily mean you need to include user interaction and account signups and a database. But I do think jQuery Mobile isn’t exactly for building websites as much as smaller web apps. The browser market has been finicky in the past, but now we’ve reached a point where the majority do support jQuery Mobile and these apps can be rapidly developed.
  • 3. 6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 3/8 Take for example my demo code below. This will output a completely empty page with a simple title and includes the 3 external documents we need for any jQM app. These include the latest JavaScript version of jQuery & jQuery Mobile, along with the default CSS styles for jQM. View the demo Of course this is just a very basic example to get us started. The same semantics still apply where you should add all your page content within the HTML body tags. But jQuery Mobile will actually let you code multiple app pages into a single HTML file. This concept is a bit confusing at first so let’s break it down. You may want to save the template above into a new index.html file. Now within this one file we can use data-roles to create a couple page elements. When your app first loads the top page will behave as your home or index. Then you would link between these pages by targeting the ID attribute. The page anatomy section gives you an overview of the additional elements you may add such as forms, inputs, headers, lists, or even a footer toolbar area. Linking Between Pages Below I have included some more example code demonstrating page links. You can add this into the body section of your own app, or modify the content a bit to your liking. What’s important here is the unique ID for for each container element and how the anchor links point to a new page. 1 <!DOCTYPEhtml> 2 <html> 3 <head> 4 <title>StandardjQMTemplate</title> 5 <linkrel="stylesheet"href="http://code.jquery.com/mobile/1.0b1/jquery.mobile 6 <scripttype="text/javascript"src="http://code.jquery.com/jquery-1.6.4.min.js 7 <scripttype="text/javascript"src="http://code.jquery.com/mobile/1.0rc2/jquer 8 </head> 9 10 <body> 11 12 </body> 13 </html> 1 <divdata-role="page"id="home"> 2 <divdata-role="header"> 3 <h1>Hereistheindexpage.</h1> 4 </div> 5 6 <divdata-role="content"> 7 <p><center>Belowyoumaytransitiontoourotherpages.</center></p> 8 9 <ahref="#about"data-role="button"data-inline="true">AboutMe</a> 10 </div> 11 </div> 12 13 <divdata-role="page"id="about"> 14 <divdata-role="header"> 15 <h1>AboutUs</h1> 16 </div> 17 18 <divdata-role="content">
  • 4. 6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 4/8 View the demo On each of the anchor links I’m taking advantage of a few more HTML data-attributes. data-role is used to change the link style from plain text into a rounded button. Similarly the inline attribute makes the button appear as a smaller limited- width box. Otherwise we have links which span the entirety of the page and just look terrible! On the About page I added a link with data-rel=”back” which you should familiarize yourself with. jQM does support browser history and you can use this attribute to simulate a back button at will. I did set the href value same as the home ID, but we could have used href=”#pork” and still gotten back to the previous view. Only because in this scenario data-rel overrides the href attribute no matter what value we put in. Mobile Page Structures After you begin to see how mobile apps are put together jQM appears more like a framework than simply a JavaScript library. And within this framework we must work with different rules compared to a regular web design. One such issue pertains to default page views how different mobile browsers will render the same code. The meta viewport tag can be added into your header to force all mobile browsers to render page zoom at 100%. This is a bigger problem with software such as Mobile Safari, as each website is purposefully scaled down to fit within the screen resolution. But adding the following tag into your header will reset this value and always keep your pages focused at the right size. The best part about this method is that you are able to customize how users experience your app. For example in my code above the user can still re-size the zoom at will if they don’t like our 100% setting. By adding user-scalable=no to the list of commands your app will be locked into the scope and overrides default browser settings. 19 <ahref="#home"data-rel="back"data-role="button"data-inline="true">&laqu 20 </div> 21 </div> 1 <metaname="viewport"content="width=device-width,initial-scale=1.0,minimum-s
  • 5. 6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 5/8 Images are also a bit difficult to manage. Ultimately as the web designer it is your choice on how to handle image sizes. I recommend keeping things below a 450px width but experiment to see what looks best. By default visitors will be able to swipe over and down to get the whole view if your image exceeds the screen size. But you can set full 100% width for iOS devices using some real basic CSS styles to fix this for most of your traffic. Remove the Loading Message One other annoyance is the modal box which appears each time you transition to another page. jQuery Mobile has this running by default which ironically may not be the most effective choice. This appears whether you are loading pages from within the same file or external individual files. To remove this we need to call upon a bit of JavaScript. This relies on jQuery commands but needs to be implemented before the jQuery Mobile library is initialized. Thus you’ll want to include this code in the middle of these 2 docs in your header area. I just added everything inline and you can check out my demo below. View the demo The mobileinit method is run immediately after jQuery Mobile has finished loading. We are binding an event handler to that method and calling our own function as a response. The setting for $.mobile.loadingMessageis generally a string of text which appears in the loading message dialog between pages. But when set to false the whole feature is disabled immediately! You can read more about global configuration and other jQM settings from their online docs. Conclusion In this brief tutorial we have covered the very basics of a jQuery Mobile application. I’ve exposed you to a basic template and the required elements for any standard page, along with some more intermediate-to-advanced level configuration stuff. After this guide you should feel a lot more comfortable toying around with the Mobile library and exploring their online documentation. If you have built your own mobile template or design we’d love to check it out. The current 1.0 release is stable and will continue with bug fixes as time progresses. Let us know your thoughts in the discussion area below along with any questions or complaints you have. 1 <scripttype="text/javascript"src="http://code.jquery.com/jquery-1.6.4.min.js" 2 <scripttype="text/javascript"> 3 $(document).bind("mobileinit",function(){ 4 $.mobile.loadingMessage=false; 5 }); 6 </script> 7 <scripttype="text/javascript"src="http://code.jquery.com/mobile/1.0rc2/jquer 8 </head>
  • 6. 6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 6/8 advertise hereadvertise here About the author: Jake is a social media enthusiast and an Internet entrepreneur. He frequently writes articles involving new-age design concepts and freelance management skills. You can find him in Google or follow his tweets @jakerocheleau Related Entries: How to Style iOS Sliding Checkboxes with jQuery Code a Dynamic Questions & Answers FAQ Page with jQuery How To Build an Alphabetical Page Index using jQuery Building a Live Textarea Character Count Limit with CSS3 and jQuery Coding an Image Thumbnail Hover Magnify Effect with jQuery Comments:
  • 7. 6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 7/8 Advertise Here Reason: Content blocked by your organization This Websense category is Options: Click more information to learn more about your access policy. Popular Articles and Resources (view archives)
  • 8. 6/17/13 Beginner’s Tutorial Coding Web Apps with jQueryMobile | SpyreStudios spyrestudios.com/beginners-tutorial-coding-web-apps-with-jquery-mobile/ 8/8 advertise hereadvertise here Copyright 2007-2011. All rights reserved. Privacy Policy