{"id":51,"date":"2013-02-07T02:51:57","date_gmt":"2013-02-07T10:51:57","guid":{"rendered":"http:\/\/courses.haigarmen.com\/desn412\/?p=51"},"modified":"2013-02-07T02:53:57","modified_gmt":"2013-02-07T10:53:57","slug":"introducing-jquery-mobile","status":"publish","type":"post","link":"https:\/\/courses.haigarmen.com\/desn412\/introducing-jquery-mobile\/","title":{"rendered":"Introducing jQuery Mobile"},"content":{"rendered":"<p>In this course we&#8217;ll be using jQuery Mobile extensively as it is a widely used open source resource for creating mobile interfaces and builds on our existing knowledge of standard web technology (HTML, CSS and Javascript).<\/p>\n<h2>What is it?<\/h2>\n<p><em><a href=\"http:\/\/jquerymobile.com\/\">jQuery Mobile<\/a> is a touch-optimized web framework for smartphones &amp; tablets.<\/em><br \/>\nA unified, HTML5-based user interface system for all popular mobile device platforms, built on the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design.<\/p>\n<h3>Let&#8217;s dig in<\/h3>\n<p>Let&#8217;s start by downloading all the components that make jQuery Mobile tick:<br \/>\nDownload the following files:<\/p>\n<ul>\n<li><a href=\"http:\/\/code.jquery.com\/jquery-1.8.3.min.js\">http:\/\/code.jquery.com\/jquery-1.8.3.min.js<\/a><\/li>\n<li><a href=\"http:\/\/code.jquery.com\/mobile\/1.2.0\/jquery.mobile-1.2.0.zip\">http:\/\/code.jquery.com\/mobile\/1.2.0\/jquery.mobile-1.2.0.zip<\/a><\/li>\n<\/ul>\n<p>Why are we not using the latest\/greatest version of jQuery or jQuery Mobile, you ask? Well, as a new javascript framework it&#8217;s is constantly evolving and I&#8217;ve supplied us we  links to versions that work well together.<\/p>\n<h3>File Structure<\/h3>\n<p>Next we&#8217;ll set up a standard file structure for our project. The final file structure can become your starting template for various projects. Here is the hierarchic structure that I&#8217;d like you to set up. <strong><em>Please note that there are no uppercase or special characters including spaces<\/em><\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/courses.haigarmen.com\/desn412\/files\/2013\/02\/file-structure.png\" alt=\"file-structure\" width=\"430\" height=\"512\" class=\"alignnone size-full wp-image-56\" srcset=\"https:\/\/courses.haigarmen.com\/desn412\/files\/2013\/02\/file-structure.png 430w, https:\/\/courses.haigarmen.com\/desn412\/files\/2013\/02\/file-structure-251x300.png 251w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/p>\n<h3>The HTML file<\/h3>\n<p>The HTML file brings all the elements together and lives on the root level of the project. Here&#8217;s what the basic HTML looks like, it should be named &#8220;index.html&#8221;:<\/p>\n<pre lang=\"HTML\">\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n\t<meta charset=\"utf-8\" \/>\r\n\t<title>View Source<\/title>\r\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1\" \/>\r\n\r\n\t<link rel=\"stylesheet\" href=\"css\/jquery.mobile-1.2.0.min.css\" \/>\r\n\t<script src=\"js\/jquery-1.8.3.min.js\"><\/script>\r\n\t<script src=\"js\/jquery.mobile.js\"><\/script>\r\n\r\n\t<script src=\"js\/myscript.js\"><\/script>\r\n\t<link rel=\"stylesheet\" href=\"css\/mystyles.css\" \/>\r\n<\/head>\r\n\t<body>\r\n\tHello World\r\n\t<\/body>\r\n<\/html>\r\n<\/pre>\n<h3>Let&#8217;s preview that<\/h3>\n<p>Open the index.html file in a webkit browser like Safari or Chrome (in this class we&#8217;ll use Chrome more for it Developer Toolkit). Make sure all of your dependencies are loading with your index.html file. You can double check this by opening the Developer Tool (under the View\/Developer\/Developer Tools menu in Chrome). Then click on the Network tab to see if every file loaded properly. If something didn&#8217;t load properly it shows as an error in red.<\/p>\n<h2>Page Structure <\/h2>\n<p>jQuery Mobile is easy but requires a shift in thinking from the traditional HTML way of creating multiple pages for websites. With jQuery Mobile all of your pages can exist within the same HTML file in separate divs. Here&#8217;s what I mean, replace &#8220;hello world&#8221; with the following code:<\/p>\n<pre lang=\"HTML\">\r\n\t<div id=\"home\" data-role=\"page\">\r\n\t\tWelcome to my home screen\r\n\t<\/div>\r\n<\/pre>\n<p>jQMobile uses the div attribute &#8216;data-role&#8217; to specify a div being a page container. The id attribute is a unique name that you assign the div and will be used to link to the page from other pages. Let&#8217;s make a second page:<\/p>\n<pre lang=\"HTML\">\r\n\t<div id=\"home\" data-role=\"page\">\r\n\t\tWelcome to my home screen\r\n\t<\/div>\r\n\t<div id=\"second\" data-role=\"page\">\r\n\t\tWelcome to my second screen\r\n\t<\/div>\r\n<\/pre>\n<p>When we preview our index.html file in the browser we can not see the second page. The reason for this is jQmobile makes the second page invisible and will only show that page once we click on a link to that page. Now let&#8217;s create that link:<\/p>\n<pre lang=\"HTML\">\r\n\t<div id=\"home\" data-role=\"page\">\r\n\t\tWelcome to my home screen\r\n<a href=\"#second\">Second page<\/a>\r\n\t<\/div>\r\n\t<div id=\"second\" data-role=\"page\">\r\n\t\tWelcome to my second screen\r\n\t<\/div>\r\n<\/pre>\n<h3>Make Another Page<\/h3>\n<p>Now it&#8217;s your turn, make a third screen and link to it from the first (home) screen.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this course we&#8217;ll be using jQuery Mobile extensively as it is a widely used open source resource for creating mobile interfaces and builds on our existing knowledge of standard web technology (HTML, CSS and Javascript). What is it? jQuery Mobile is a touch-optimized web framework for smartphones &amp; tablets. A unified, HTML5-based user interface [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-articles","category-tutorials"],"_links":{"self":[{"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":13,"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/posts\/51\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/desn412\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}