JQuery JQueryMobile: Difference between revisions

From Wiki RB4
Line 1: Line 1:
==Concepts==
==Concepts==
jMobile web pages consist of different pages often as part of a single HTML file and each with a header, content and footer section:
jMobile web pages consist of different [[#page_role|pages]] often as part of a single HTML file and each with a header, content and footer section:
  &lt;div data-role="page" id="p1">content p1</div>  
  &lt;div data-role="page" id="p1">content p1</div>  
  &lt;div data-role="page" id="p2">content p2</div>
  &lt;div data-role="page" id="p2">content p2</div>

Revision as of 12:39, 2 June 2014

Concepts

jMobile web pages consist of different pages often as part of a single HTML file and each with a header, content and footer section:

<div data-role="page" id="p1">content p1 <div data-role="page" id="p2">content p2

Transition is often implementet as

<a href="p2">...</a>

Templates

A good reference can be found here:

<script id="bookTemplate" type="text/x-jQuery-tmpl">

API

  • getting attributes of elements: $('<element name>').attr('<attribute name>')
  • setting attributes of elements: $('a').attr({<attribute name>: '<value>', <attribute name>: '<value>'});
  • id names are prefixed with #
  • class names are prefixed with .

jQuery()

  • $() is short of jQuery()


getJSON()

$.getJSON('car-sale-report.json', function() {
  //callback
});

is equivalent to below

$.ajax({
  url: url,
  dataType: 'json', //json data type
  data: data,
  success: callback,
  error: callback
});

data roles

data-roles

button role

content role

footer role

data-position="fixed"

header role

listview role

data-inset="true" // creates margins around the list within a content area

page role

data-theme="[a|b|c]" define standard colors and fonts

<a>

data-icon="[home|grid|info]"
data-iconpos="notext"
data-transition="slidedown" // defines the optical transition to another page

<select>

data-native-menu=[true|false]" // enables self customization of select optic


<ul>

data-role="listview"
data-filter="true" // makes the list searchable

Resources