Introduction to jQuery Mobile (jQM) - cont'd
Getting started with jQM
-Downloading the Most Recent Version of jQuery Mobile
-Proper Markup for Loading Framework JavaScript and CSS
jQuery Mobile Page Structure
-Page Anatomy: Header, Footer and Content Sections
-Header and Footer Toolbars
-Bundling Pages into a Single Document
-Navigating Between Pages
Applying Different Theme Swatches
Page Initialization Events
jQuery Mobile Page Components
Basic Content Formatting
List Views
-Ordered and Unordered Lists
-Inset Lists
-Lists with Links
-Nested Lists
-Lists with Icons or Thumbnail Images
-Split Button Lists
-List Dividers
-Search Filters
Form Controls - check boxes, slider, etc.
Dialogs
Buttons and Toolbars
-Ways to Make a Button
-Placing Icons on Your Buttons
-Inline Buttons
-Button Groupings
-Navigation Toolbars
Collapsible Content
Event Handling
-Responding to various events
-Page related events
Ajax & Interaction with server (REST & SOAP)
Deployment using Phonegap (e.g. Android)
Overview of Android Devt Environment
Best Practices in jQM
Hands-on exercises
jQuery Mobile: Progressive Enhancement with HTML5Todd Anderson
An overview of the jQuery Mobile framework and its foundation on Progressive Enhancement, as well as a few techniques on breaking a jQM application from the "traditional" browser.
This is very basic presentation focused on jQuery mobile, where it highlighted why people will choose it, and how easily anybody can start on it. It was developed for our in house presentation.
Introduction to the jQuery mobile frameworkRishabh Rao
This presentation gives a quick overview of the jQuery mobile framework and an introduction on how to use jQuery mobile.
A lot of details are yet to be included. Hope I get the time to do so!
Introduction to jquery mobile with PhonegapRakesh Jha
Introduction to jQuery Mobile (jQM) - cont'd
Getting started with jQM
-Downloading the Most Recent Version of jQuery Mobile
-Proper Markup for Loading Framework JavaScript and CSS
jQuery Mobile Page Structure
-Page Anatomy: Header, Footer and Content Sections
-Header and Footer Toolbars
-Bundling Pages into a Single Document
-Navigating Between Pages
Applying Different Theme Swatches
Page Initialization Events
jQuery Mobile Page Components
Basic Content Formatting
List Views
-Ordered and Unordered Lists
-Inset Lists
-Lists with Links
-Nested Lists
-Lists with Icons or Thumbnail Images
-Split Button Lists
-List Dividers
-Search Filters
Form Controls - check boxes, slider, etc.
Practical jump start for learning how to use the jQueryMobile library.
More information about the Java course I deliver can be found at java.course.lifemichael.com
More information about the PHP course I deliver can be found at php.course.lifemichael.com
More information about the FED course I deliver can be found at fed.course.lifemichael.com
More information about the Scala course I deliver can be found at scala.course.lifemichael.com
More information about the Android course I deliver can be found at android.course.lifemichael.com
More information about the Kotlin course I deliver can be found at kotlin.course.lifemichael.com
More information about the Swift course I deliver can be found at swift.course.lifemichael.com
More information about the C++ course I deliver can be found at cpp.course.lifemichael.com
More information about the Go course I deliver can be found at go.course.lifemichael.com
More information about the CSS course I deliver can be found at css.course.lifemichael.com
More information about the C# course I deliver can be found at csharp.course.lifemichael.com
More information about the Python course I deliver can be found at python.course.lifemichael.com
More information about the Angular course I deliver can be found at angular.course.lifemichael.com
More information about the Node.js course I deliver can be found at nodejs.course.lifemichael.com
More information about the Fullstack Development course I deliver can be found at fullstack.course.lifemichael.com
jQuery Mobile: Progressive Enhancement with HTML5Todd Anderson
An overview of the jQuery Mobile framework and its foundation on Progressive Enhancement, as well as a few techniques on breaking a jQM application from the "traditional" browser.
This is very basic presentation focused on jQuery mobile, where it highlighted why people will choose it, and how easily anybody can start on it. It was developed for our in house presentation.
Introduction to the jQuery mobile frameworkRishabh Rao
This presentation gives a quick overview of the jQuery mobile framework and an introduction on how to use jQuery mobile.
A lot of details are yet to be included. Hope I get the time to do so!
Introduction to jquery mobile with PhonegapRakesh Jha
Introduction to jQuery Mobile (jQM) - cont'd
Getting started with jQM
-Downloading the Most Recent Version of jQuery Mobile
-Proper Markup for Loading Framework JavaScript and CSS
jQuery Mobile Page Structure
-Page Anatomy: Header, Footer and Content Sections
-Header and Footer Toolbars
-Bundling Pages into a Single Document
-Navigating Between Pages
Applying Different Theme Swatches
Page Initialization Events
jQuery Mobile Page Components
Basic Content Formatting
List Views
-Ordered and Unordered Lists
-Inset Lists
-Lists with Links
-Nested Lists
-Lists with Icons or Thumbnail Images
-Split Button Lists
-List Dividers
-Search Filters
Form Controls - check boxes, slider, etc.
Practical jump start for learning how to use the jQueryMobile library.
More information about the Java course I deliver can be found at java.course.lifemichael.com
More information about the PHP course I deliver can be found at php.course.lifemichael.com
More information about the FED course I deliver can be found at fed.course.lifemichael.com
More information about the Scala course I deliver can be found at scala.course.lifemichael.com
More information about the Android course I deliver can be found at android.course.lifemichael.com
More information about the Kotlin course I deliver can be found at kotlin.course.lifemichael.com
More information about the Swift course I deliver can be found at swift.course.lifemichael.com
More information about the C++ course I deliver can be found at cpp.course.lifemichael.com
More information about the Go course I deliver can be found at go.course.lifemichael.com
More information about the CSS course I deliver can be found at css.course.lifemichael.com
More information about the C# course I deliver can be found at csharp.course.lifemichael.com
More information about the Python course I deliver can be found at python.course.lifemichael.com
More information about the Angular course I deliver can be found at angular.course.lifemichael.com
More information about the Node.js course I deliver can be found at nodejs.course.lifemichael.com
More information about the Fullstack Development course I deliver can be found at fullstack.course.lifemichael.com
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
APEX& jQuery Mobile
Binnenkort zal Oracle versie de lang aangekondigde upgrade naar release 4.2 van Oracle Application Express beschikbaar maken. Een van de meest besproken nieuwe features die voor dit nieuwe release zijn aangekondigd is de integratie van het jQuery Mobile framework. Met de integratie van dit framework zal het mogelijk worden om met APEX applicaties te ontwikkelen, die geschikt zijn voor mobiele toestellen.
Wat is en hoe werkt jQuery Mobile en wat betekend dit voor het ontwikkelen in APEX. Dat zijn de onderwerpen die de presentatie aan bod komen. En waarom wachten tot het release van 4.2. Het is namelijk nu al mogelijk om jQuery Mobile in APEX te integreren en gebruiken. Hoe, wordt in een demo getoond. Deze sessie is waarschijnlijk de enige waarin u gevraagd zal worden om uw mobile telefoon aan te laten staan.
Introduction to jQuery Mobile - Web Deliver for AllMarc Grabanski
Mobile web development frameworks are targeting the builtin web browsers on iPhone and Android only; however, jQuery mobile has in a different vision, one that will reach the largest distribution of phones possible. Leveraging the ways of progressive enhancement, your website can be viewed in raw HTML on old mobile phones and then enhanced with nice CSS styles across mobile platforms that have a decent CSS and JavaScript support. In this session, Grabanski gives you his list of reasons to use jQuery mobile, an overview of the framework and will draw from his experiences building websites on top of jQuery Mobile.
Last year, AOL adopted a new content strategy and has positioned itself as a premier destination for original content. Core to this strategy is having reusable, highly efficient and optimized common code and experiences at scale, which is where jQuery comes in. Check in with Dave Artz to see how jQuery has helped his front-end standards team tackle unique challenges like optimizing 3rd party widget performance, overriding plugin functionality, and managing dependencies and updates across 100+ sites spanning multiple back-end platforms.
Don't Worry jQuery is very Easy:Learning Tips For jQueryshabab shihan
If for whatever reason you don’t know jQuery, it is a “write less, do more” JavaScript library. It has many Ajax and JavaScript features to allow you enhance semantic coding and user experience.
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapNick Landry
The final demo for this presentation can be downloaded at:
https://www.dropbox.com/s/9j09wip6wz84b61/JSDevConMobile-JQM-PhoneGap-Demo.zip
SESSION ABSTRACT
=================
Write Once, Run Everywhere. How many times have we been promised true cross-platform development? HTML5 seems to be the closest we’ve ever been to writing applications once and running them on multiple mobile devices, such as iOS, Android, Windows Phone or Blackberry.
But native mobile apps have taken all the spotlight in recent years thanks to the introduction of hundreds of thousands of apps in various app stores from Apple, Google, Microsoft and BlackBerry. Apps offer a great native platform experience, but they can be expensive to build and require specific languages, SDKs and skill sets across multiple platforms. Mobile web sites offer a great way to engage with consumers and corporate workers alike without requiring the installation of any app, and can in turn be adapted as deployable "hybrid" apps.
This session explores the fundamentals of native vs. web apps, and how to choose the right approach for any given scenario. We begin with an exploration of the benefits of web development for smartphones using the most popular HTML5 & JavaScript framework for mobile: jQuery Mobile (JQM). We’ll go over a quick primer on HTML5, CSS3 and JavaScript, followed by everything you need to get started with JQM. We’ll cover the most common development environment options, how to build your first jQuery Mobile page, and how to debug your mobile web code with some of the available tools. We’ll also discuss how to develop a native-like experience on each mobile platform thanks to JQM’s adaptive rendering, and how to save and retrieve data with the cloud using Microsoft Azure Mobile Services.
We'll then learn how to leverage PhoneGap to wrap our mobile web UI into a native smartphone or tablet app. Discover how PhoneGap exposes native device hardware like cameras, sensors, GPS and more. We’ll also discuss the pros and cons of PhoneGap-based apps, how to deal with the UI design guidelines across platforms, and learn some do’s and don’ts of cross-platform mobile development.
Native mobile apps have their place for mass market revenue-generating models, but you also need to master cross-platform techniques when the situation calls for it such as in enterprise mobility scenarios and other niche areas. Web development is a critical skill required by every mobile developer; come learn how to get started and reach hundreds of millions of users through a smart mobile web & hybrid approach.
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
APEX& jQuery Mobile
Binnenkort zal Oracle versie de lang aangekondigde upgrade naar release 4.2 van Oracle Application Express beschikbaar maken. Een van de meest besproken nieuwe features die voor dit nieuwe release zijn aangekondigd is de integratie van het jQuery Mobile framework. Met de integratie van dit framework zal het mogelijk worden om met APEX applicaties te ontwikkelen, die geschikt zijn voor mobiele toestellen.
Wat is en hoe werkt jQuery Mobile en wat betekend dit voor het ontwikkelen in APEX. Dat zijn de onderwerpen die de presentatie aan bod komen. En waarom wachten tot het release van 4.2. Het is namelijk nu al mogelijk om jQuery Mobile in APEX te integreren en gebruiken. Hoe, wordt in een demo getoond. Deze sessie is waarschijnlijk de enige waarin u gevraagd zal worden om uw mobile telefoon aan te laten staan.
Introduction to jQuery Mobile - Web Deliver for AllMarc Grabanski
Mobile web development frameworks are targeting the builtin web browsers on iPhone and Android only; however, jQuery mobile has in a different vision, one that will reach the largest distribution of phones possible. Leveraging the ways of progressive enhancement, your website can be viewed in raw HTML on old mobile phones and then enhanced with nice CSS styles across mobile platforms that have a decent CSS and JavaScript support. In this session, Grabanski gives you his list of reasons to use jQuery mobile, an overview of the framework and will draw from his experiences building websites on top of jQuery Mobile.
Last year, AOL adopted a new content strategy and has positioned itself as a premier destination for original content. Core to this strategy is having reusable, highly efficient and optimized common code and experiences at scale, which is where jQuery comes in. Check in with Dave Artz to see how jQuery has helped his front-end standards team tackle unique challenges like optimizing 3rd party widget performance, overriding plugin functionality, and managing dependencies and updates across 100+ sites spanning multiple back-end platforms.
Don't Worry jQuery is very Easy:Learning Tips For jQueryshabab shihan
If for whatever reason you don’t know jQuery, it is a “write less, do more” JavaScript library. It has many Ajax and JavaScript features to allow you enhance semantic coding and user experience.
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapNick Landry
The final demo for this presentation can be downloaded at:
https://www.dropbox.com/s/9j09wip6wz84b61/JSDevConMobile-JQM-PhoneGap-Demo.zip
SESSION ABSTRACT
=================
Write Once, Run Everywhere. How many times have we been promised true cross-platform development? HTML5 seems to be the closest we’ve ever been to writing applications once and running them on multiple mobile devices, such as iOS, Android, Windows Phone or Blackberry.
But native mobile apps have taken all the spotlight in recent years thanks to the introduction of hundreds of thousands of apps in various app stores from Apple, Google, Microsoft and BlackBerry. Apps offer a great native platform experience, but they can be expensive to build and require specific languages, SDKs and skill sets across multiple platforms. Mobile web sites offer a great way to engage with consumers and corporate workers alike without requiring the installation of any app, and can in turn be adapted as deployable "hybrid" apps.
This session explores the fundamentals of native vs. web apps, and how to choose the right approach for any given scenario. We begin with an exploration of the benefits of web development for smartphones using the most popular HTML5 & JavaScript framework for mobile: jQuery Mobile (JQM). We’ll go over a quick primer on HTML5, CSS3 and JavaScript, followed by everything you need to get started with JQM. We’ll cover the most common development environment options, how to build your first jQuery Mobile page, and how to debug your mobile web code with some of the available tools. We’ll also discuss how to develop a native-like experience on each mobile platform thanks to JQM’s adaptive rendering, and how to save and retrieve data with the cloud using Microsoft Azure Mobile Services.
We'll then learn how to leverage PhoneGap to wrap our mobile web UI into a native smartphone or tablet app. Discover how PhoneGap exposes native device hardware like cameras, sensors, GPS and more. We’ll also discuss the pros and cons of PhoneGap-based apps, how to deal with the UI design guidelines across platforms, and learn some do’s and don’ts of cross-platform mobile development.
Native mobile apps have their place for mass market revenue-generating models, but you also need to master cross-platform techniques when the situation calls for it such as in enterprise mobility scenarios and other niche areas. Web development is a critical skill required by every mobile developer; come learn how to get started and reach hundreds of millions of users through a smart mobile web & hybrid approach.
Charla que di en el WordPress Euskadi en mayo de 2016. En la charla doy unas pautas sobre los temas hijos o Child themes en WordPress. En la charla se explica en un principio qué hacer cuando se crea una instancia de WordPress y posteriormente qué son los temas hijo o Child themes, sus ventajas y qué archivos hacen falta para crear un tema hijo o Child Theme
WAP- Wireless Application Protocol
by
Team 11 Presenters:
Suma Pramod Connie Barbosa
Niti Pandey Patrick Cunning
Olga Pavlenko
This ppt contains the topic like,,
WAP Introduction,
WAP architecture requirements,
Architecture overview,
World-wide web model,
WAP model,
Components of WAP architecture,
Sample Configuration of WAP technology,
Usage, Advantages & Disadvantages of WAP,
Wireless Application Protocol (WAP),
Wireless Markup Language (WML),
Generating WML with XSLT,
WAP Emulator.
JavaScript is one of the 3 languages all web developers must learn:
1. HTML to define the content of web pages
2. CSS to specify the layout of web pages
3. JavaScript to program the behavior of web pages
Downloading jQuery file from jQuery website.
Referring to jQuery file through Content Delivery Networks.
Google CDN
<script src=http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js>
</script>
Microsoft CDN
<script src=“http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.0.min.js”>
</script>
jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code.
One of the most important factor for failure or delaying in Project deliverable is Project Manager and not having clear picture and agenda by manager.
So, question is being a good project manager, make sure that deliverable's on time, what are the key points project manager should follow.
What is mobile wallet
MW is a solution for commercial transaction across domain and geography. Such as Osaifu Keitai, Smart Wallet, Softcard, Google Wallet, Passbook, MasterPass etc. Lots of solutions is available in market but still mobile wallets are n an early stage of market.
If we defined Mobile Wallet in One line, it is equivalent to the physical wallet (wallet in pocket) and which can be used for purchasing goods, cloths, services at any time and any location. It can be in form of ID or social security card, health card, payment card, tickets for transport, or movies or events, hotel bill, gift and coupons.
Mobile applications testing (challenges, tools & techniques)Rakesh Jha
Device Fragmentation is a Big Challenge
Devices Vary in Screen Size, Memory, Processing Power, Hardware Features etc.
Apple iPhone is Least Fragmented among All Mobile Platforms
Testing on All Target Handset/Devices
Almost Impractical if Number of Target Handsets is Large
Testing on All Target Operator Networks
Almost Impractical if Number of Target Operators is Large
Network Operator may Impose Certain Constraints
Introduction
Mobile Trends
Mobile Evolution
Top Ten Trends
Mobile Ecosystem
Smartphone Trends
Mobile Application Testing
Application Option
Approach to QA
Challenges
Implementation
Introduction to PhoneGap
Background
Setting up the environment for Android
Handling Events
Working With The Device, The Network, And Notifications
Getting Information from the Device
Determining the Connection Type
Using Notifications
Using Alerts
Using Confirmation Dialogs
Using Beeps
Using Vibrations
Accelerometer
Using the Acceleration Object
Using Accelerometer Methods
Media
The Media Object
Using Media Methods
Camera
Using The Camera Object
Using The Getpicture Method
Using Camera Options
Geolocation
Position, PositionError, Coord
Geolocation Methods
Geolocation Options
Deployment using Phonegap (Android)
Hands-on exercises
Storage
Available options
Db object
localStorage
Files
Filessystem
File read & write
Handling errors
Contacts
Creating contacts
Finding contacts
Handling errors
Capture
Video
Audio
Handling errors
Hands-on exercises
Introduction to PhoneGap
Background
Setting up the environment for Android
Handling Events
Working With The Device, The Network, And Notifications
Getting Information from the Device
Determining the Connection Type
Using Notifications
Using Alerts
Using Confirmation Dialogs
Using Beeps
Using Vibrations
Accelerometer
Using the Acceleration Object
Using Accelerometer Methods
Media
The Media Object
Using Media Methods
Camera
Using The Camera Object
Using The Getpicture Method
Using Camera Options
Geolocation
Position, PositionError, Coord
Geolocation Methods
Geolocation Options
Deployment using Phonegap (Android)
Hands-on exercises
Storage
Available options
Db object
localStorage
Files
Filessystem
File read & write
Handling errors
Contacts
Creating contacts
Finding contacts
Handling errors
Capture
Video
Audio
Handling errors
Hands-on exercises
Introduction to CSS3
Text Formatting
Selectors
Box Model
Links, Backgrounds
Lists, Tables
Positioning & Layout
New features of CSS3 - transition, tranform, etc.
Introduction to jQueryMobile
Hands-on exercises
HTML5 Home
HTML5 Forms
HTML5 Reference
HTML5 Tags
HTML5 Canvas
Audio And Video
HTML5 new features
New Elements
New Attributes
Full CSS3 Support
Video and Audio
2D/3D Graphics
Local Storage
Local SQL Database
Web Applications
Native development kit (ndk) introductionRakesh Jha
Native development kit (ndk) introduction
Topics covered include •
o What is an NDK and Why NDK? •
o Java Native Interface (JNI) •
o Using NDK •
o NDK and JNI by Example •
o NDK's Stable APIs
• Android NDK Multithreading
o Introduction To NDK Native Threading
o Creating and terminating native threads at Android NDK
Build with pthreads
Thread creation
Thread termination
o Synchronizing native threads with conditional variables at Android NDK
Initialize and destroy conditional variables
o Synchronizing native threads with semaphore at Android NDK
Initialize and destroy a semaphore
o Managing data for native threads at Android NDK
Multithreading and concurrency in androidRakesh Jha
Here you will learn -
What is Multithreading
What is concurrency
Process Vs Thread
Improvements and issues with concurrency
Limits of concurrency gains
Concurrency issues
Threads pools with the Executor Framework
AsyncTask and the UI Thread
Code
2. Contents
Introduction to jQuery Mobile (jQM)
Getting started with jQM
-Downloading the Most Recent Version of jQuery Mobile
-Proper Markup for Loading Framework JavaScript and CSS
jQuery Mobile Page Structure
-Page Anatomy: Header, Footer and Content Sections
-Header and Footer Toolbars
-Bundling Pages into a Single Document
-Navigating Between Pages
Applying Different Theme Swatches
Page Initialization Events
jQuery Mobile Page Components
Basic Content Formatting
List Views
-Ordered and Unordered Lists
-Inset Lists
-Lists with Links
-Nested Lists
-Lists with Icons or Thumbnail Images
-Split Button Lists
-List Dividers
-Search Filters
Form Controls - check boxes, slider, etc.
3. Introduction to jQuery Mobile (jQM)
•jQuery is a JavaScript Library.
•jQuery greatly simplifies JavaScript programming.
•jQuery is easy to learn
4. Introduction to jQuery Mobile (jQM)
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</body>
</html>
5. jQuery Introduction
•The purpose of jQuery is to make it much easier to use JavaScript on your website.
6. What is jQuery
•jQuery is a lightweight, "write less, do more", JavaScript library.
•The purpose of jQuery is to make it much easier to use JavaScript on your website.
7. What is jQuery
•jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, and wraps them into methods that you can call with a single line of code
8. What is jQuery
•The jQuery library contains the following features:
–HTML/DOM manipulation
–CSS manipulation
–HTML event methods
–Effects and animations
–AJAX
–Utilities
9. Why jQuery
•The jQuery library contains the following features:
–Easy to use
–Less LOC
–Simplify code
–Rich api
10. jQuery Install
•There are several ways to start using jQuery on your web site. You can:
–Download the jQuery library from jQuery.com
–Include jQuery from a CDN, like Google
11. Downloading jQuery
•There are two versions of jQuery available for downloading:
–Production version - this is for your live website because it has been minified and compressed
–Development version - this is for testing and development (uncompressed and readable code)
http://jquery.com/download/
12. Downloading jQuery
•The jQuery library is a single JavaScript file, and you reference it with the HTML <script> tag (notice that the <script> tag should be inside the <head> section):
<head> <script src="jquery-1.11.1.min.js"></script> </head>
13. jQuery CDN
•If you don't want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).
<head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> </head>
14. jQuery CDN
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
15. jQuery Syntax
•With jQuery you select (query) HTML elements and perform "actions" on them.
•The jQuery syntax is tailor made for selecting HTML elements and performing some action on the element(s).
16. jQuery Syntax
•Basic syntax is: $(selector).action()
–A $ sign to define/access jQuery
–A (selector) to "query (or find)" HTML elements
–A jQuery action() to be performed on the element(s)
17. jQuery Syntax
•Examples:
–$(this).hide() - hides the current element.
–$("p").hide() - hides all <p> elements.
–$(".test").hide() - hides all elements with class="test".
–$("#test").hide() - hides the element with id="test".
18. The Document Ready Event
$(document).ready(function()
{ // jQuery methods go here... });
This is to prevent any jQuery code from running before the document is finished loading (is ready).
19. The Document Ready Event
•It is good practice to wait for the document to be fully loaded and ready before working with it.
•This also allows you to have your JavaScript code before the body of your document, in the head section.
20. The Document Ready Event
•Here are some examples of actions that can fail if methods are run before the document is fully loaded:
–Trying to hide an element that is not created yet
–Trying to get the size of an image that is not loaded yet
21. The Document Ready Event
•The jQuery team has also created an even shorter method for the document ready event:
$(function(){ // jQuery methods go here... });
23. The element Selector
•All selectors in jQuery start with the dollar sign and parentheses: $().
•The jQuery element selector selects elements based on the element name.
•You can select all <p> elements on a page like this:
24. jQuery selectors
•jQuery selectors are one of the most important parts of the jQuery library
•jQuery selectors allow you to select and manipulate HTML element(s)
•jQuery selectors are used to "find" (or select) HTML elements based on their id, classes, types, attributes, values of attributes
25. jQuery selectors
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
26. The #id Selector
•The jQuery #id selector uses the id attribute of an HTML tag to find the specific element.
•An id should be unique within a page, so you should use the #id selector when you want to find a single, unique element.
27. The #id Selector
•To find an element with a specific id, write a hash character, followed by the id of the HTML element:
$("#test")
28. The #id Selector
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#test").hide();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p id="test">This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
29. The .class Selector
•The jQuery class selector finds elements with a specific class.
•To find elements with a specific class, write a period character, followed by the name of the class:
$(".test")
•
30. The .class Selector
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$(".test").hide();
});
});
</script>
</head>
<body>
<h2 class="test">This is a heading</h2>
<p class="test">This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
31. The .class Selector
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("*").hide();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
32. The .class Selector
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
33. The .class Selector
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p.intro").hide();
});
});
</script>
</head>
<body>
<h2 class="intro">This is a heading</h2>
<p class="intro">This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>
</body>
</html>
36. Functions In a Separate File
•If your website contains a lot of pages, and you want your jQuery functions to be easy to maintain, you can put your jQuery functions in a separate .js file.
<head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script> <script src="my_jquery_functions.js"></script> </head>
38. jQuery Event Methods
•jQuery is tailor-made to respond to events in an HTML page.
39. What are Events?
•All the different visitor's actions that a web page can respond to are called events.
•An event represents the precise moment when something happens.
•Examples:
–moving a mouse over an element
–selecting a radio button
–clicking on an element
40. What are Events?
Mouse Events
Keyboard Events
Form Events
Document/Window Events
click
keypress
submit
load
dblclick
keydown
change
resize
mouseenter
keyup
focus
scroll
mouseleave
blur
unload
41. jQuery Syntax For Event Methods
•In jQuery, most DOM events have an equivalent jQuery method.
•To assign a click event to all paragraphs on a page, you can do this:
42. jQuery Syntax For Event Methods
$("p").click();
•The next step is to define what should happen when the event fires. You must pass a function to the event:
$("p").click(function(){ // action goes here!! });
47. Header and Footer Toolbars
•Toolbar elements are often placed inside headers and footers - for "easy-access" navigation:
48. Header Bars
•The header is located at the top of the page and usually contain a page title/logo or one or two buttons (typically home, options or search).
•You can add buttons to the left and/or to the right side in the header.
49. Header Bars
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-icon-home ui-btn-icon-left">Home</a>
<h1>Welcome To My Homepage</h1>
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-icon-search ui-btn-icon-left">Search</a>
</div>
<div data-role="main" class="ui-content">
<p>Notice that we have added the CSS class of "ui-corner-all" and "ui-shadow" to the header buttons, to make them look a bit more desirable.</p>
</div>
</div>
</body>
</html>
52. Footer Bars
•The footer is located at the bottom of the page.
•The footer is more flexible than the header - it is more functional and changeable throughout pages, and can therefore contain as many buttons as needed:
•The buttons in the footer are not centered by default. To fix this, simply use CSS:
<div data-role="footer" style="text-align:center;">
53. Footer Bars
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-icon-home ui-btn-icon-left ">Home</a>
<h1>Welcome To My Homepage</h1>
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-icon-search ui-btn-icon-left ">Search</a>
</div>
<div data-role="main" class="ui-content">
<p>The buttons are for demonstration purposes only, and will not have any effect.</p>
<p>Notice that we have applied the CSS class of "ui-corner-all" and "ui-shadow" to the buttons in both the header and footer, to make them look more desirable.</p>
</div>
<div data-role="footer">
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-icon-plus ui-btn-icon-left">Add Me On Facebook</a>
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-icon-plus ui-btn-icon-left">Add Me On Twitter</a>
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-icon-plus ui-btn-icon-left">Add Me On Instagram</a>
</div>
</div>
</body>
</html>
54. Positioning Headers and Footers
•The header and the footer can be positioned in three ways:
–Inline - Default. Headers and footers are inline with the page content
–Fixed - Headers and footers will remain positioned at the top and bottom of the page
–Fullscreen - Behaves like fixed; headers and footers will remain positioned at the top and bottom, but also over the page content. It is also slightly see-through
55. Positioning Headers and Footers
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header" data-position="fixed">
<h1>Inline Header</h1>
</div>
<div data-role="main" class="ui-content">
<p><b>Tip:</b> To see the effect, try to resize the window if the scrollbar is not available.</p>
<p>Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..</p>
</div>
<div data-role="footer" data-position="inline">
<h1>Inline Footer</h1>
</div>
</div>
</body>
</html>
56. Navigating Between Pages
•A navigation bar consists of a group of links that are aligned horizontally, typically within a header or footer
•The bar is coded as an unordered list of links wrapped inside a <div> element that has the data-role="navbar" attribute
59. Active Buttons
•When a link in the navbar is tapped/clicked, it gets the selected (pressed down) look.
•To achieve this look without having to tap the link, use the class="ui-btn-active":
60. <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
<div data-role="navbar">
<ul>
<li><a href="#" class="ui-btn-active" data-icon="home">Home</a></li>
<li><a href="#pagetwo" data-icon="arrow-r">Page Two</a></li>
</ul>
</div>
</div>
<div data-role="main" class="ui-content">
<p>With the ui-btn-active class, notice that the Home button stays highlighted (selected).</p>
<p>If you click on the Page Two, you will notice that none of the buttons are highlighted (selected).</p>
</div>
<div data-role="footer">
<h1>My Footer</h1>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
<div data-role="navbar">
<ul>
<li><a href="#pageone" data-icon="home">Home</a></li>
<li><a href="#" data-icon="arrow-r">Page Two</a></li>
</ul>
</div>
</div>
<div data-role="main" class="ui-content">
<p>No buttons are pre-selected (highlighted) in this page..</p>
<p>To get the selected look for each button that represents the page you are actually on, go back to our navbar tutorial and read the next step to find out how!</p>
</div>
<div data-role="footer">
<h1>My Footer</h1>
</div>
</div>
</body>
</html>
62. Applying Different Theme Swatches
•jQuery Mobile provides two different style themes, "a" and "b" - each with different colors for buttons, bars, content blocks, and so on.
63. Applying Different Theme Swatches
•To customize the look of your application, use the data-theme attribute, and assign the attribute with a letter:
<div data-role="page" data-theme="a|b">
67. jQuery Mobile Pages
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>I Am Now A Mobile Developer!!</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
68. jQuery Mobile Pages
•The data-role="page" is the page displayed in the browser
•The data-role="header" creates a toolbar at the top of the page (often used for title or search buttons)
•The data-role="main" defines the content of the page, like text, images, buttons, forms, etc.
•The "ui-content" class adds extra padding and margin inside the page content
•The data-role="footer" creates a toolbar at the bottom of the page
•Inside these containers, you can add any HTML elements - paragraphs, images, headings, lists, etc.
69. Adding Pages in jQuery Mobile
•In jQuery Mobile, you can create multiple pages in a single HTML file.
•Separate each page with a unique id and use the href attribute to link between them:
70. Adding Pages in jQuery Mobile
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>Welcome! If you click on the link below, it will take you to Page Two.</p>
<a href="#pagetwo">Go to Page Two</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>This is Page Two. If you click on the link below, it will take you to Page One.</p>
<a href="#pageone">Go to Page One</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
71. Using Pages as Dialogs
•A dialog box is a type of window used to show special information or request input.
•To create a dialog box that opens when a user taps on a link, add data-dialog="true" to the page you want displayed as a dialog:
72. Using Pages as Dialogs
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>Welcome!</p>
<a href="#pagetwo">Go to Dialog Page</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" data-dialog="true" id="pagetwo">
<div data-role="header">
<h1>I'm A Dialog Box!</h1>
</div>
<div data-role="main" class="ui-content">
<p>The dialog box is different from a normal page, it is displayed on top of the current page and it will not span the entire width of the page. The dialog has also an icon of "X" in the header to close the box.</p>
<a href="#pageone">Go to Page One</a>
</div>
<div data-role="footer">
<h1>Footer Text In Dialog</h1>
</div>
</div>
</body>
</html>
74. jQuery Mobile List Views
•List views in jQuery Mobile are standard HTML lists; ordered (<ol>) and unordered (<ul>).
•To create a list, apply the data-role="listview" to the <ol> or <ul> element. To make the items tappable, specify a link inside each list item (<li>):
78. List Dividers
•List dividers are used to organize and group items into categories/sections.
•To specify a list divider, add the data-role="list- divider" attribute to an <li> element:
80. List Dividers
•If you have an alphabetically list, (for example a phone book) jQuery Mobile automatically adds appropriate dividers by setting the data- autodividers="true" attribute on the <ol> or <ul> element:
83. jQuery Mobile List Icons
•The default icon for each list item containing a link is "carat-r" (right arrow).
•To change this to another icon, use the data- icon attribute on the list item you want to modify:
85. jQuery Mobile List Icons
data-icon="false" will remove the icon
•To add a standard 16x16px icon to your list, add an <img> element inside the link with a class of "ui-li-icon":
89. Dialogs
Buttons and Toolbars
-Ways to Make a Button
-Placing Icons on Your Buttons
-Inline Buttons
-Button Groupings
-Navigation Toolbars
Collapsible Content
Event Handling
-Responding to various events
-Page related events
Deployment using Phonegap (e.g. Android)
Overview of Android Devt Environment
Best Practices in jQM
Hands-on exercises
90. Split Buttons
•To create a split list with a vertical divider bar, place two links inside the <li> element.
•jQuery Mobile will automatically place the second link on the right side of the list with a right arrow-icon. And the text inside the link (if any) will be shown when a user hover over the icon:
91. Split Buttons
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="main" class="ui-content">
<h2>Split Buttons</h2>
<ul data-role="listview" data-inset="true">
<li>
<a href="#">
<img src="chrome.png">
<h2>Google Chrome</h2>
<p>Google Chrome is a free, open-source web browser. Released in 2008.</p>
</a>
<a href="#">Some Text</a>
</li>
<li>
<a href="#">
<img src="firefox.png">
<h2>Mozilla Firefox</h2>
<p>Firefox is a web browser from Mozilla. Released in 2004.</p>
</a>
<a href="#">Some Text</a>
</li>
</ul>
</div>
</div>
</body>
</html>
92. Count Bubbles
•Count bubbles are used to display numbers associated with list items, such as messages in a mailbox:
94. Placing Icons on Your Buttons
•Mobile applications are built upon the simplicity of tapping things you'd want displayed
95. Creating a Button in jQuery Mobile
•A button in jQuery Mobile can be created in three ways:
–Using the <input> element
–Using the <button> element with class="ui-btn"
–Using the <a> element with class="ui-btn"
98. Grouped Buttons
•jQuery Mobile provides an easy way for grouping buttons together.
•Use the data-role="controlgroup" attribute together with data-type="horizontal|vertical" in a container element, to specify whether to group buttons horizontally or vertically:
102. Inline Buttons
•By default, buttons take up the full width of the screen.
•If you want a button that is only as wide as its content, or if you want two or more buttons to appear side by side, add the "ui-btn-inline" class:
103. Inline Buttons
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>Normal / Default button:</p>
<a href="#pagetwo" class="ui-btn">Go to Page Two</a>
<p>Inline button:</p>
<a href="#pagetwo" class="ui-btn ui-btn-inline">Go to Page Two</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Welcome To My Homepage</h1>
</div>
<div data-role="main" class="ui-content">
<p>Inline buttons (will appear side by side as long as the screen lets it):</p>
<a href="#pageone" class="ui-btn ui-btn-inline">Go to Page One</a>
<a href="#pageone" class="ui-btn ui-btn-inline">Go to Page One</a>
<a href="#pageone" class="ui-btn ui-btn-inline">Go to Page One</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
106. Collapsible Content
•Collapsibles allow you to hide or show content, which is useful for storing parts of information.
•To create a collapsible block of content, assign the data-role="collapsible" attribute to a container. Inside the container (div), add a header (H1-H6) or legend element, followed by any HTML markup you want to be expanded:
108. Nested Collapsible Blocks
•Collapsible content blocks can be nested (a collapsible inside a collapsible):
109. Nested Collapsible Blocks
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Nested Collapsible Blocks</h1>
</div>
<div data-role="main" class="ui-content">
<div data-role="collapsible">
<h1>Click me - I'm collapsible!</h1>
<p>I'm the expanded content.</p>
<div data-role="collapsible">
<h1>Click me - I'm a nested collapsible block!</h1>
<p>I'm the expanded content in the nested collapsible block.</p>
</div>
</div>
</div>
<div data-role="footer">
<h1>Insert Footer Text Here</h1>
</div>
</div>
</body>
</html>
110. Collapsible Sets
•Collapsible sets are collapsible blocks that are grouped together (often referred to as an accordion). When a new block is opened, all other blocks close.
•Create several collapsible content blocks, and then wrap a new container with the data- role="collapsibleset" around the collapsible blocks:
112. Event Handling
•Events = All the different visitor's actions that a web page can respond to.
113. jQuery Mobile Events
•Events = All the different visitor's actions that a web page can respond to.
114. jQuery Mobile Events
•You can use any standard jQuery events in jQuery Mobile.
•In addition, jQuery Mobile also offers several events that are tailor-made for mobile-browsing:
–Touch events - triggers when a user touches the screen (tap and swipe)
–Scroll events - triggers when a user scrolls up and down
–Orientation events - triggers when the device rotates vertically or horizontally
–Page events - triggers when a page is shown, hidden, created, loaded and/or unloaded
115. Initializing jQuery Mobile Events
•In jQuery, you have learned to use the document ready event to prevent any jQuery code from running before the document is finished loading (is ready):
116. Initializing jQuery Mobile Events
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("p").on("click",function(){
$(this).hide();
});
});
</script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</body>
</html>
117. Initializing jQuery Mobile Events
•However, in jQuery Mobile, we use the pagecreate event, which occurs when the page has been been created in the DOM, but before enhancement is complete.
•The second parameter ("#pageone") points to the id of the page to specify the event(s) for:
118. Initializing jQuery Mobile Events
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagecreate","#pageone",function(){
$("p").on("click",function(){
$(this).hide();
});
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Header Text</h1>
</div>
<div data-role="main" class="ui-content">
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
119. jQuery Mobile Touch Events
•Touch events are triggered when the user touches the screen (page).
120. jQuery Mobile Tap
•The tap event is triggered when the user taps on an element.
•The following example says: When a tap event fires on a <p> element; hide the current <p> element:
121. jQuery Mobile Tap
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagecreate","#pageone",function(){
$("p").on("tap",function(){
$(this).hide();
});
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>The tap Event</h1>
</div>
<div data-role="main" class="ui-content">
<p>If you tap me, I will disappear.</p>
<p>Tap me away!</p>
<p>Tap me too!</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
122. jQuery Mobile Taphold
•The taphold event is triggered when the user taps on an element and hold for one second:
123. jQuery Mobile Taphold
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagecreate","#pageone",function(){
$("p").on("taphold",function(){
$(this).hide();
});
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>The taphold Event</h1>
</div>
<div data-role="main" class="ui-content">
<p>If you tap and hold me for one second, I will disappear.</p>
<p>Tap and hold me!</p>
<p>Tap and hold me too!</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
124. jQuery Mobile Swipe
•The swipe event is triggered when the user swipes over an element horizontally by more than 30px:
126. jQuery Mobile Swipeleft
•The swipeleft event is triggered when the user swipes over an element in the left direction by more than 30px:
127. jQuery Mobile Swipeleft
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagecreate","#pageone",function(){
$("p").on("swipeleft",function(){
alert("You swiped left!");
});
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>The swipeleft Event</h1>
</div>
<div data-role="main" class="ui-content">
<p style="border:1px solid black;margin:5px;">Swipe me in the left direction - do not swipe outside the border!</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
128. jQuery Mobile Swiperight
•The swiperight event is triggered when the user drags over an element in the right direction by more than 30px:
129. jQuery Mobile Swiperight
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagecreate","#pageone",function(){
$("p").on("swiperight",function(){
alert("You swiped right!");
});
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>The swiperight Event</h1>
</div>
<div data-role="main" class="ui-content">
<p style="border:1px solid black;margin:5px;">Swipe me in the right direction - do not swipe outside the border!</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
130. jQuery Mobile Scroll Events
•jQuery Mobile provides two scroll events: when scrolling starts and when scrolling stops.
131. jQuery Mobile Scrollstart
•The scrollstart event is triggered when the user starts to scroll the page:
132. jQuery Mobile Scrollstart
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagecreate","#pageone",function(){
$(document).on("scrollstart",function(){
alert("Started scrolling!");
});
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>The scrollstart Event</h1>
</div>
<div data-role="main" class="ui-content">
<p><b>Tip:</b> Try to to resize the window if the scrollbar is not available.</p>
<p>Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..Some text to enable scrolling..</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
133. jQuery Mobile orientationchange Event
•The orientationchange event is triggered when the user rotates the mobile device vertically or horizontally.
134. jQuery Mobile orientationchange Event
•The orientationchange event is triggered when the user rotates the mobile device vertically or horizontally.
$(window).on("orientationchange",function(){ alert("The orientation has changed!"); });
135. jQuery Mobile orientationchange Event
•The callback function can have one argument, the event object, which returns the orientation of the mobile device: "portrait" (the device is held in a vertical position) or "landscape" (the device is held in a horizontal position):
136. jQuery Mobile orientationchange Event
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagecreate",function(event){
$(window).on("orientationchange",function(event){
alert("Orientation changed to: " + event.orientation);
});
});
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>The orientationchange Event</h1>
</div>
<div data-role="main" class="ui-content">
<p>Try to rotate your device!</p>
<p><b>Note:</b> You must use a mobile device, or a mobile emulator to see the effect of this event.</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
137. jQuery Mobile orientationchange Event
•Because the orientationchange event is bound to the window object, we can use the window.orientation property to, for example, set different styles to distinguish between portrait and landscape views:
138. <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagecreate",function(event){
$(window).on("orientationchange",function(){
if(window.orientation == 0)
{
$("p").text("The orientation has changed to portrait!").css({"background-color":"yellow","font-size":"300%"});
}
else
{
$("p").text("The orientation has changed to landscape!").css({"background-color":"pink","font-size":"200%"});
}
});
});
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>The orientationchange Event</h1>
</div>
<div data-role="main" class="ui-content">
<p>Try to rotate your device!</p>
<p><b>Note:</b> You must use a mobile device, or a mobile emulator to see the effect of this event.</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
139. jQuery Mobile Page Events
•Events for handling pages in jQuery Mobile are divided into four categories:
–Page Initialization - Before page creation, and when the page has been created
–Page Load/Unload - When an external page is loading, unloading or encounters a failure
–Page Transition - Before and after page transitions
–Page Change - When pages are changed to or from, or encounters a failure
140. jQuery Mobile Initialization Events
•When a typical page in jQuery Mobile is initialized, it goes through two stages:
–Before page creation
–Page creation
141. jQuery Mobile Initialization Events
•Each stage has an event that can be used to insert or manipulate code before or when jQuery Mobile enhances the page.
Event
Description
pagebeforecreate
Triggered when the page is about to be initialized, and before jQuery Mobile has started enhancing the page
pagecreate
Triggered when the page has been created, but before enhancement is complete
142. jQuery Mobile Initialization Events
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagebeforecreate",function(){
alert("pagebeforecreate event fired - the page is about to be initialized. jQuery Mobile has not begun enhancing the page");
});
$(document).on("pagecreate",function(){
alert("pagecreate event fired - the page has been created, but enhancement is not complete");
});
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Header Text</h1>
</div>
<div data-role="main" class="ui-content">
<p>The page has been created and enhancement is done!</p>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
143. jQuery Mobile Load Events
•Page load events are for external pages.
•Whenever an external page is loaded into the DOM, 2 events fire.
•The first is pagecontainerbeforeload, and the second will either be pagecontainerload (success) or pagecontainerloadfailed (fail).
144. jQuery Mobile Load Events
Event
Description
pagecontainerbeforeload
Triggered before any page load request is made
pagecontainerload
Triggered after the page has been successfully loaded and inserted into the DOM
pagecontainerloadfailed
Triggered if the page load request fails. By default, it will show the "Error Loading Page" message
146. jQuery Mobile Transition Events
•We can also use events for when we transition from one page to the next.
•Page transitions involve two pages: a "from" page and a "to" page - these transitions animate the change from the current active page (fromPage) to a new page (toPage).
147. jQuery Mobile Transition Events
Event
Description
pagebeforeshow
Triggered on the "to" page, before the transition animation starts
pageshow
Triggered on the "to" page, after the transition animation completes
pagebeforehide
Triggered on the "from" page, before the transition animation starts
pagehide
Triggered on the "from" page, after the transition animation completes
148. <!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>
<script>
$(document).on("pagebeforeshow","#pagetwo",function(){
alert("pagebeforeshow event fired - pagetwo is about to be shown");
});
$(document).on("pageshow","#pagetwo",function(){
alert("pageshow event fired - pagetwo is now shown");
});
$(document).on("pagebeforehide","#pagetwo",function(){
alert("pagebeforehide event fired - pagetwo is about to be hidden");
});
$(document).on("pagehide","#pagetwo",function(){
alert("pagehide event fired - pagetwo is now hidden");
});
</script>
</head>
<body>
<div data-role="page" id="pageone">
<div data-role="header">
<h1>Header Text</h1>
</div>
<div data-role="main" class="ui-content">
<p>Page One</p>
<a href="#pagetwo">Go to Page Two</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
<div data-role="page" id="pagetwo">
<div data-role="header">
<h1>Header Text</h1>
</div>
<div data-role="main" class="ui-content">
<p>Page Two</p>
<a href="#pageone">Go Back to Page One</a>
</div>
<div data-role="footer">
<h1>Footer Text</h1>
</div>
</div>
</body>
</html>
150. Ajax & Interaction with server (REST & SOAP)
•As jQuery becomes ever more widespread, we get asked a lot about integration with databases.
•This article is target at those taking their first step into the world of jQuery and integrating pages with a Database.
•The same principles could also be used with a different datasource such as XML.
151. Ajax & Interaction with server (REST & SOAP)
•The first method we will look at is where basic information is sent back to the client and displayed within a container.
•We start by setting the standard Javascript blocks on the page.
152. Ajax & Interaction with server (REST & SOAP)
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
//jQuery code will go here...
</script>
153. Ajax & Interaction with server (REST & SOAP)
•Next we set up the html that will be located in the html of the page itself
155. Ajax & Interaction with server (REST & SOAP)
•Next we add the jQuery script elements.
•As this is a process that will be called by some user interaction, we will need to add the script and also add an event to the button that we added to the page.
156. Ajax & Interaction with server (REST & SOAP)
function GetMember() {
$('input[type=button]').attr('disabled', true);
$("#MemberDetails").html('');
$("#MemberDetails").addClass("loading");
$.ajax({
type: "POST",
url: "Members.asmx/GetMemberDetails",
data: "{'MemberNumber': '" + $("#txt_id").val() + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnGetMemberSuccess,
error: OnGetMemberError
});
}
function OnGetMemberSuccess(data, status) {
//jQuery code will go here...
}
function OnGetMemberError(request, status, error) {
//jQuery code will go here...
}
157. GetMember
•This is the main stage in our process and is called by the button being clicked. Once called it follows a number of stages:
–Sets the button to disabled - to prevent duplicate clicks
–Clears the html in the MemberDetails div.
–Adds the loading class to the div - this in reality would show a loading icon.
–Calls the ajax element to process the data
–Follows either the success or error results by calling the appropriate function.
158. GetMember
•type - you would normally use Get or Post here depending on your requirement
•url - the path to the web service asmx file and the web method you are going to call
•data - in this instance the MemberNumber that we are going to pass
•contentType, dataType - specifying we are going to use json formatting
•success - what to do on success
•error - what to do following an error
159. Displaying Collections
•Sometimes, we require more than to display simple text and may wish to return the data in a format that can be displayed on multiple end clients.
•In such cases, just the raw data is returned and formatted as determined by the client.
•Firstly, we enter the core elements of the page again as before
160. Displaying Collections
<script src="Scripts/jquery-1.4.1.js" type="text/javascript">
</script>
<script type="text/javascript">
//jQuery code will go here...
</script>
161. Displaying Collections
•Next we set up the html that will be located in the html of the page itself
<p>
<input id="btnLoadAll" type="button" value="Get All Members" />
</p>
<div id="MemberList"></div>
162. Displaying Collections
function GetAllMembers() {
$("#MemberList").html('');
$("#MemberList").addClass("loading");
$.ajax({
type: "POST",
url: "Members.asmx/GetAllMembers",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnGetAllMembersSuccess,
error: OnGetAllMembersError
});
}
function OnGetAllMembersSuccess(data, status) {
//jQuery code will go here...
}
function OnGetAllMembersError(request, status, error) {
//jQuery code will go here...
}
163. Displaying Collections
•Next we set up the html that will be located in the html of the page itself
<p>
<input id="btnLoadAll" type="button" value="Get All Members" />
</p>
<div id="MemberList"></div>