100% found this document useful (2 votes)
17 views

jQuery Mobile 1st Edition Jon Reid - The ebook in PDF/DOCX format is available for instant download

The document promotes instant access to various ebooks, particularly focusing on jQuery Mobile and its applications in mobile web development. It includes links to multiple titles related to jQuery and mobile web development, along with a brief overview of the jQuery Mobile library and its capabilities. Additionally, it outlines the structure of a book that serves as a guide to using jQuery Mobile effectively for creating mobile applications.

Uploaded by

sabirababaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
17 views

jQuery Mobile 1st Edition Jon Reid - The ebook in PDF/DOCX format is available for instant download

The document promotes instant access to various ebooks, particularly focusing on jQuery Mobile and its applications in mobile web development. It includes links to multiple titles related to jQuery and mobile web development, along with a brief overview of the jQuery Mobile library and its capabilities. Additionally, it outlines the structure of a book that serves as a guide to using jQuery Mobile effectively for creating mobile applications.

Uploaded by

sabirababaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 85

Instant Ebook Access, One Click Away – Begin at ebookgate.

com

jQuery Mobile 1st Edition Jon Reid

https://ebookgate.com/product/jquery-mobile-1st-edition-jon-
reid/

OR CLICK BUTTON

DOWLOAD EBOOK

Get Instant Ebook Downloads – Browse at https://ebookgate.com


Click here to visit ebookgate.com and download ebook now
Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

jQuery Mobile Web Development Essentials 2nd Edition Build


mobile optimized websites using the simple practical and
powerful jQuery based framework Raymond Camden
https://ebookgate.com/product/jquery-mobile-web-development-
essentials-2nd-edition-build-mobile-optimized-websites-using-the-
simple-practical-and-powerful-jquery-based-framework-raymond-camden/
ebookgate.com

Reid s Read alouds 2 Rob Reid

https://ebookgate.com/product/reid-s-read-alouds-2-rob-reid/

ebookgate.com

jQuery For Dummies 1st Edition Lynn Beighley

https://ebookgate.com/product/jquery-for-dummies-1st-edition-lynn-
beighley/

ebookgate.com

jQuery Pocket Primer Oswald Campesato

https://ebookgate.com/product/jquery-pocket-primer-oswald-campesato/

ebookgate.com
Head First jQuery Ryan Benedetti

https://ebookgate.com/product/head-first-jquery-ryan-benedetti/

ebookgate.com

Learning jQuery 4th Edition Jonathan Chaffer

https://ebookgate.com/product/learning-jquery-4th-edition-jonathan-
chaffer/

ebookgate.com

Dunbar 1650 Comwell s Most Famous Victory by Stuart Reid


Stuart Reid

https://ebookgate.com/product/dunbar-1650-comwell-s-most-famous-
victory-by-stuart-reid-stuart-reid/

ebookgate.com

Herbal Chinese cooking Reid

https://ebookgate.com/product/herbal-chinese-cooking-reid/

ebookgate.com

jQuery in Action Third Edition Bear Bibeault

https://ebookgate.com/product/jquery-in-action-third-edition-bear-
bibeault/

ebookgate.com
www.it-ebooks.info
www.it-ebooks.info
Download from Wow! eBook <www.wowebook.com>

jQuery Mobile
www.it-ebooks.info
www.it-ebooks.info
www.it-ebooks.info

jQuery Mobile

Jon Reid

Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo


www.it-ebooks.info

jQuery Mobile
by Jon Reid

Copyright © 2011 Jonathan Reid. All rights reserved.


Printed in the United States of America.

Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.

O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or [email protected].

Editor: Mary Treseler Cover Designer: Karen Montgomery


Production Editor: Jasmine Perez Interior Designer: David Futato
Proofreader: Jasmine Perez Illustrator: Robert Romano

Printing History:
June 2011: First Edition.

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. jQuery Mobile, the image of the squirrel tree toad, and related trade dress are
trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.

ISBN: 978-1-449-30668-7

[LSI]

1307713150
www.it-ebooks.info

Table of Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

1. Meet jQuery Mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


Overview of the jQuery Mobile Library 1
How jQuery Mobile Works 2
Create Your First jQuery Mobile Application 2
Under The Hood: the jqmData() Custom Selector 7

2. Application Structure and Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9


Pages 9
Internal Pages 10
External Pages 12
Under The Hood: Page Initialization in jQuery Mobile 15
Page Hide and Show Events 17
Dialogs 20
Navigation and History 20
Transitions 22
Under The Hood: Animations in a jQuery Mobile Application 23

3. Page Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Under The Hood: jQuery Plug-ins and Widgets 25
List Views 26
Basic List View 26
Advanced List Views 29
Under The Hood: Updating a List View 39
Toolbars 39
Navigation Bars 39
Positioning the Header and Footer 43
Buttons 44
Button Control Groups 46
Button Icons 47

v
www.it-ebooks.info

Form Elements 49
Accessing Form Elements with JavaScript 49
Checkboxes and Radio Buttons 50
Flip Toggle 52
Input Fields and Textareas 53
Search Fields 54
Select Menus 55
Sliders 59
Layout Grids 61

4. Theming jQuery Mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65


Themes and Swatches 65
Under The Hood: Customizing a Swatch 74
Theming List View Elements 78

5. jQuery Mobile API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79


jQuery Mobile Methods 79
changePage 79
pageLoading 80
silentScroll 80
addResolutionBreakpoints 80
Events 81
Touch Events 81
Initialization Events 83
Page Hide and Show Events 84
Scroll Events 85
Orientation Change Events 85
Responsive Layout API 85
CSS Selectors 85
Configuring jQuery Mobile 88
Available Options 88
Changing an Option via mobileinit 89
Under The Hood: Namespacing Data Attributes 90

6. jQuery Mobile in Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93


Application Pages 93
Initializing the Application 97
The initMainPage Method 97
The initSettings Method 102
The initDetailPage Method 103
Error Dialog 103
jqmTweet Take One 104
Improving the Interface 106

vi | Table of Contents
www.it-ebooks.info

CSS Tweaks 106


Interaction Tweaks 106
Overall Approach 111

Table of Contents | vii


www.it-ebooks.info
www.it-ebooks.info

Preface

Introduction
Mobile applications come in two basic flavors: native applications, which are compiled
programs that run natively on the device, and mobile web applications, which run
inside a web browser on the device.
Native applications get almost all of the press these days, especially given the financial
success of the iTunes App Store and the Android Market. And with good reason, as
native applications have many advantages: they are fast, have access to all of the power
of the platform they are built for, and so forth. However, native applications suffer from
one important limitation: they are not portable. If you want to make your application
available on multiple platforms, you either have to write it in multiple languages
(resulting in multiple code bases to maintain) or use a platform abstraction layer like
Titanium or PhoneGap.
Mobile web applications, on the other hand, are created in HTML, CSS, and JavaScript,
and run in the web browser on the mobile device. This means one code base to maintain,
but mobile web applications still need to account for variations in web browsers across
platforms.
Enter jQuery Mobile. Based on the popular jQuery JavaScript library, jQuery Mobile
is designed to create mobile web applications that function on a broad range of devices.
With jQuery Mobile, it is possible to quickly create mobile web applications that look
and behave consistently across all supported devices, and that have advanced user
interface capabilities. jQuery Mobile gives the developer a standard set of layouts, user
interface widgets, and interactions, as well as a rich API for applying and extending
them.
jQuery Mobile is not yet in production—as of this writing, it is in its Alpha 4 release,
with the beta coming soon.
Even so, the library already has a broad set of features and is remarkably stable. In fact,
I have already used it in one production project with great success, and if you review
posts on the jQuery Mobile forums, you’ll see that there are many people using jQuery

ix
www.it-ebooks.info

Mobile in production. As jQuery Mobile advances, we hope to update this ebook to


cover new features and provide new tips and techniques.

What This Book Covers


This book covers how the jQuery Mobile library works, and how to use it to create
mobile web applications. While I was writing this book I was engaged in a project in
which I was using jQuery Mobile to create a mobile web application. This gave me a
unique insight into how to use jQuery Mobile in a production environment, so this
book takes a practical approach for using the library and focuses on example code and
screenshots. In addition, throughout the book there are “Under The Hood” sections
where I explore a topic in more detail: page initialization, using swipe events to trigger
page transitions, animation in a jQuery Mobile application, and so forth.
In Chapter 1, we will provide a high-level overview of jQuery Mobile, how it works,
and how to use it. If you follow the examples in the chapter, at the end of the chapter
you will have built your first jQuery Mobile application. It won’t do much, but it will
show how easy it is to set up a jQuery Mobile application and introduce you to some
important jQuery Mobile concepts.
Chapter 2 covers paging and navigation in jQuery Mobile, including dialogs, AJAX
content, and history.
In Chapter 3, we will cover the UI elements that jQuery Mobile can create: toolbars,
buttons, lists, form elements, and layout grids.
In Chapter 4, we will cover the jQuery Mobile theme framework, how to use it, and
how to customize it.
In Chapter 5, we will take a look at the new events that jQuery Mobile creates, the
methods it exposes, and how to customize jQuery Mobile for your own applications.
Chapter 6 is where we will put everything together and build an actual mobile appli-
cation: jqmTweet. We’ll walk through how to approach building a mobile application
with jQuery Mobile from start to finish.

What You Need To Know


This book assumes you are already familiar with the jQuery JavaScript library. You
should be able to create jQuery selectors and apply jQuery methods to them.
This book assumes you are familiar with HTML markup and Cascading Style Sheets.
Throughout the code examples, we will be using HTML 5 and CSS 3, and employing
industry best practices like semantic markup and progressive enhancement.
This book also assumes that you have a basic familiarity with mobile web browsers.
Though jQuery Mobile aims to provide a cross-platform API, it is still necessary for a
mobile web developer to understand mobile browsers and their capabilities.

x | Preface
www.it-ebooks.info

Finally, this book assumes you are familiar with the technologies of the web: HTTP,
clients and servers, security, etc.

Conventions Used In This Book


The following typographical conventions are used in this book:
Italic
Indicates a term, URL, email address, or filenames or extensions.
Constant Width
Used for code examples and for code elements such as variable names, function
names, keywords, etc. that are included in regular paragraphs.
Constant width italic
Shows text that should be replaced with user-supplied values or by values deter-
Download from Wow! eBook <www.wowebook.com>

mined by context.

This signifies a tip, suggestion, or note of interest.

This indicates a warning or caution: a bug in the library, a common


problem, etc.

Using Code Examples


This book is here to help you get your job done. In general, you may use the code in
this book in your programs and documentation. You do not need to contact us for
permission unless you’re reproducing a significant portion of the code. For example,
writing a program that uses several chunks of code from this book does not require
permission. Selling or distributing a CD-ROM of examples from O’Reilly books does
require permission. Answering a question by citing this book and quoting example
code does not require permission. Incorporating a significant amount of example code
from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title,
author, publisher, and ISBN. For example: “jQuery Mobile by Jon Reid (O’Reilly).
Copyright 2011 Jonathan Reid, 978-1-449-30668-7.”
If you feel your use of code examples falls outside fair use or the permission given above,
feel free to contact us at [email protected].

Preface | xi
www.it-ebooks.info

Safari® Books Online


Safari Books Online is an on-demand digital library that lets you easily
search over 7,500 technology and creative reference books and videos to
find the answers you need quickly.
With a subscription, you can read any page and watch any video from our library online.
Read books on your cell phone and mobile devices. Access new titles before they are
available for print, and get exclusive access to manuscripts in development and post
feedback for the authors. Copy and paste code samples, organize your favorites, down-
load chapters, bookmark key sections, create notes, print out pages, and benefit from
tons of other time-saving features.
O’Reilly Media has uploaded this book to the Safari Books Online service. To have full
digital access to this book and others on similar topics from O’Reilly and other pub-
lishers, sign up for free at http://my.safaribooksonline.com.

How to Contact Us
Please address comments and questions concerning this book to the publisher:
O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional
information. You can access this page at:
http://www.oreilly.com/catalog/0636920020585
To comment or ask technical questions about this book, send email to:
[email protected]
For more information about our books, courses, conferences, and news, see our website
at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia

xii | Preface
www.it-ebooks.info

Acknowledgments
I’d like to thank RJ Owen for volunteering to do the technical review of this book. His
honesty and encouragement helped make this book a success.
I also want to thank Juan Sanchez for providing suggestions for the “Under The Hood”
sections in the book.
The HTML development team at EffectiveUI patiently listened to me rave about jQuery
Mobile and obsess about this book: Aaron Congleton, Ryan McGinty, Kevin Bauman,
Shane Church, Tony Walt, and George Robison. Thanks, guys.

Preface | xiii
www.it-ebooks.info
www.it-ebooks.info

CHAPTER 1
Meet jQuery Mobile

jQuery Mobile is a set of jQuery plug-ins and widgets that aim to provide a cross-
platform API for creating mobile web applications. In terms of code implementation,
jQuery Mobile is very similar to jQuery UI, but while jQuery UI is focused on desktop
applications, jQuery Mobile is built with mobile devices in mind.
As of this writing, jQuery Mobile is still in its Alpha 4 release, with beta just around
the corner. There are still plenty of issues that are being fixed, but the jQuery Mobile
development team has said that they consider the library to be feature-complete for
their 1.0 release. Although the documentation is sparse, especially compared to the
extensive documentation for the jQuery project itself, the forums are very active.
Even so, many people are already using jQuery Mobile in production, which is a
testament not only to the stability and quality of the library, but of how easy it is to use.

Overview of the jQuery Mobile Library


As of this writing, jQuery Mobile consists of four files: a JavaScript file, a CSS file, and
two PNG graphic sprites.
The JavaScript file is meant to be loaded after the base jQuery library. This script file
performs various tasks, like creating widgets, applying event listeners, and enabling the
API.
jQuery Mobile also includes a Cascading Style Sheet which specifies layout and
appearance of jQuery Mobile page elements. The Style Sheet also specifies transitions
and animations with CSS3 transforms.
Finally, jQuery Mobile includes a small set of graphics for user interface elements. These
are simple, standardized icons for navigation.
You can download the entire jQuery Mobile package (the JavaScript library, the CSS,
and the graphics) or you can access them through the project’s CDN. See the jQuery
Mobile project download page for specifics. In the examples for this book, we will be
using the CDN.

1
www.it-ebooks.info

How jQuery Mobile Works


jQuery Mobile uses HTML 5 and CSS 3 features to enhance basic HTML markup to
create a consistent mobile experience across supported platforms. jQuery Mobile
makes heavy use of the HTML 5 specification for custom data- attributes (available for
review at http://dev.w3.org/html5/spec/elements.html#embedding-custom-non-visible
-data-with-the-data-attributes). Using this method, it is possible to embed data into
valid HTML 5 markup. jQuery Mobile has a large vocabulary of data- attributes.
Upon initialization, jQuery Mobile selects elements based on their data- attributes and
enhances them by inserting extra markup, adding new CSS classes, and applying event
handlers. This enables you to quickly write basic semantic markup and leave it to
jQuery Mobile to transform your simple markup into complex user interface elements.

It’s actually an interesting exercise to see what jQuery Mobile adds to


your basic markup. To do this, you will need the ability to view source
both before and after JavaScript has been applied to a page—in most
browsers, the “view source” menu option will only show you the
unenhanced source. However, most browsers have “view generated
source” plug-ins available, and the ability to view generated source is
built into some browser-based web development toolbars.

Create Your First jQuery Mobile Application


The best way to understand jQuery Mobile is to dive right in. Begin by creating a simple
HTML 5 page that includes the jQuery and jQuery Mobile libraries, as shown in
Example 1-1.
Example 1-1. Basic HTML5 page for a jQuery Mobile application
<!DOCTYPE html>
<html>
<head>
<title>jQuery Mobile Application</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4.1/
jquery.mobile-1.0a4.1.min.css" />
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js">
</script>
</head>
<body>
</body>
</html>

2 | Chapter 1: Meet jQuery Mobile


www.it-ebooks.info

This includes everything you need to start building a jQuery Mobile application.
Next, we need to include some content. Content should be marked up semantically,
and since we’re using HTML 5, we have access to all of the new tags like header, footer,
section, nav, etc. We can mark up our content using those tags, or we simply block off
our content using div tags.
For our first example, we want to create a page in our application that is a self-contained
section, with a header, content area, and footer. (We’ll discuss the details of pages and
views in jQuery Mobile in the next chapter. For now, we’ll just focus on the simplest
case.) Using div-based markup, we would create something like what is shown in
Example 1-2.
Example 1-2. Old and busted: div-based markup
<div class="section" id="page1">
<div class="header"><h1>jQuery Mobile</h1></div>
<div class="content">
<p>First page!</p>
</div>
<div class="footer"><h1>O'Reilly</h1></div>
</div>

Or we can mark up the same content using the HTML 5 tags section, header, and
footer, as shown in Example 1-3.

Example 1-3. New hotness: HTML 5 markup


<section id="page1">
<header><h1>jQuery Mobile</h1></header>
<div class="content">
<p>First page!</p>
</div>
<footer><h1>O'Reilly</h1></footer>
</section>

jQuery Mobile will work with either markup style, though as we move forward in this
book, we will use the HTML 5 markup.
jQuery Mobile doesn’t need specific markup, but it does need us to indicate the roles
of the content areas somehow. To do this, jQuery Mobile uses a custom data- attribute:
data-role. Valid data-role values include page, header, content, and footer.
This is our first encounter with a custom data- attribute. jQuery Mobile uses them
extensively to designate functionality, layout, and behaviors. We’ll learn more about
them in later chapters, so for right now we’ll just focus on the data-role attribute.
Applying the appropriate data-role attributes, our HTML 5 markup would be written
as shown in Example 1-4.

Create Your First jQuery Mobile Application | 3


www.it-ebooks.info

Example 1-4. jQuery Mobile data-role attributes applied to HTML 5 markup


<section id="page1" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div class="content" data-role="content">
<p>First page!</p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>

That is all you need to do to create an application in jQuery Mobile. It will do all the
rest for you.
To view your new web application, you can run it locally in an HTML 5 capable browser
(such as Safari), as shown in Figure 1-1.

Figure 1-1. First page in Safari

This will give you an idea of what it will look like and how it will perform, but to really
test the application you will need to view it in a mobile device.
You can use various emulators that come with the platform application development
SDKs, but the ideal way to test the application is to serve it via a web server and use a
mobile device to browse it. This will give you the best feel for how the application
behaves.

4 | Chapter 1: Meet jQuery Mobile


www.it-ebooks.info

Setting yourself up to serve your content locally is actually quite easy.


My favorite drop-in tool is XAMPP, available at http://www.apache
friends.org/en/xampp.html. It is available for Windows, OS X, Linux,
and Solaris, and has great step-by-step tutorials and how-to guides.

Throughout this book, we will be using screen shots from an iPhone, and our current
application is shown in Figure 1-2.

Figure 1-2. First page in iPhone

Adding another page is a simple matter of copying and pasting our code and changing
the id of the containing section and updating the content to reflect a new page, as
shown in Example 1-5.
Example 1-5. Adding a second page to the sample application
<section id="page2" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div class="content" data-role="content">
<p>Second page!</p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>

Create Your First jQuery Mobile Application | 5


www.it-ebooks.info

Navigation between pages is simple: just add a link to your content area in the first
page of the application, as shown in Example 1-6.
Example 1-6. Adding a link to second page
<div class="content" data-role="content">
<p>First page!</p>
<p><a href="#page2">Go to the second page!</a></p>
</div>

Now when you refresh the application, you will see a link to tap, as shown in Figure 1-3.

Figure 1-3. Link to next page

Tapping the link will transition to the next screen. jQuery Mobile will automatically
handle the page transition animation, and will automatically provide a back button in
the header.
Tapping on the back button will return you to the previous page, and again jQuery
Mobile will automatically handle the page transition.
There you have it, your first jQuery Mobile application. It doesn’t do much, but it
should give you some insight into the simplicity of the framework. All you have to do

6 | Chapter 1: Meet jQuery Mobile


www.it-ebooks.info

is mark up your content semantically and then designate roles, functionality, and
interactions using custom data- attributes. Then sit back and allow jQuery Mobile to
do all the work for you.

Under The Hood: the jqmData() Custom Selector


jQuery Mobile has a new custom selector that it uses to select elements with data-
attributes. You’re probably already familiar with jQuery’s other built in custom selec-
tors, which include :has(), :contains(), :eq(), etc. These selectors can be used either
to directly select elements (e.g. $("div:contains('foo')")) or they can be used to filter
other selectors (e.g. $("div").contains('foo')).
You can select all elements with a data-role="page" attribute using the standard jQuery
selector $("[data-role='page']"). This works fine, but since jQuery Mobile relies so
heavily on custom data- attributes, it made sense to build a custom selector: jqmData().
Download from Wow! eBook <www.wowebook.com>

To use jqmData() to select all elements with a data-role="page", you would use
$(":jqmData(role='page')"). To select all elements with any custom data- attribute
within those selected pages, you could use $(":jqmData(role='page')").jqmData(role).
The jqmData() selector also automatically handles namespacing. Since jQuery Mobile
relies so heavily on data attributes, you should be able to apply a namespace to them
to avoid conflicts with other data attributes that won’t be used by jQuery Mobile. (For
example, instead of data-role="page", it could use data-namespace-role="page" where
namespace- is a configurable string.) By default, jQuery Mobile does not apply a name-
space, but it can be configured to do so using the $.mobile.ns configuration option (see
“Configuring jQuery Mobile” on page 88 in Chapter 5 for more information). If you
do configure a namespace, the jqmData() selector will automatically account for it.
There was an interesting discussion around adding the namespacing feature to jQuery
Mobile, which you can read over on the project’s GitHub at https://github.com/jquery/
jquery-mobile/issues/196.

Create Your First jQuery Mobile Application | 7


www.it-ebooks.info
www.it-ebooks.info

CHAPTER 2
Application Structure and Navigation

Pages
As we saw in our first example, jQuery Mobile designates pages using the data-role
attribute. Behind the scenes, jQuery Mobile selects elements based on this attribute
and progressively enhances them, adding CSS classes, any needed markup, and event
management. This may seem like a complicated way of handling things—why not
simply have regular pages linked like you ordinarily would?—but this methodology
gives jQuery Mobile several important features:
Page Transitions
By handling pages as separate content areas in one document, jQuery Mobile can
create smooth page transitions, resulting in an overall “application-like” look and
feel.
Navigation Management
jQuery Mobile can automatically handle page navigation, providing features like
back buttons and deep linking.
Efficiency
Since resources are all contained in one file, the browser does not have to access
the network over and over again, as it would with smaller individual files. This will
help mitigate application slowness and battery drain on the mobile device. The
trade-off is that for a large application there could be an appreciable download
time for a large HTML page with many individual jQuery Mobile page views.
However, once the file is downloaded and ready, the behavior will be much faster
and will not necessarily be dependent on network access.

9
www.it-ebooks.info

Internal Pages
As we have already seen, we can mark discreet sections of content as pages within the
application with the data-role="page". These sections must be top-level siblings in the
document body; it is not possible to nest pages within one another. As shown in
Example 2-1, a single HTML document can have as many of these pages as desired.
Example 2-1. Multiple internal pages in one HTML document
<!-- begin first page -->
<section id="page1" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>First page!</p>
<p><a href="#page2">Go to Second Page</a></p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>
<!-- end first page -->

<!-- Begin second page -->


<section id="page2" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>Second page!</p>
<p><a href="#page3">Go to Third Page</a></p>
</div>
<foote data-role="footer"r><h1>O'Reilly</h1></footer>
</section>
<!-- end second page -->

<!-- begin third page -->


<section id="page3" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>Third page!</p>
<p><a href="#page1">Go back to First Page</a></p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>
<!-- end third page -->

jQuery Mobile will automatically handle page transitions, back buttons, etc., as the
user clicks through the resulting pages of the application (see Figures 2-1, 2-2, and 2-3).

10 | Chapter 2: Application Structure and Navigation


www.it-ebooks.info

Figure 2-1. Multiple pages (page 1)

Figure 2-2. Multiple pages (page 2)

Pages | 11
www.it-ebooks.info

Figure 2-3. Multiple pages (page 3)

External Pages
jQuery Mobile will also handle external pages as well. If you link to a separate page
instead of to an ID of a data-role="page" element within the current document, jQuery
Mobile will perform an asynchronous fetch of the requested page and integrate it into
the current document, allowing it to perform its page management functions.
jQuery Mobile will fetch the external page and search through it for the first element
marked with a data-role="page" attribute and insert that into the DOM of the origin
document. Any other content, including subsequent elements with data-role="page"
attributes, will be ignored.
If jQuery Mobile fails to retrieve the page, or if it retrieves the page but fails to find a
data-role="page" designated element, it will display an error message.

12 | Chapter 2: Application Structure and Navigation


www.it-ebooks.info

To add an external page to our previous example code, create a file called
“external.html” and include the markup shown in Example 2-2.
Example 2-2. External.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>

<p>This content will be ignored.</p>

<!-- Begin Page 4 -->


<section id="page4" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div class="content" data-role="content">
<p>External Page!</p>
<p><a href="#page1">Go to First Page</a>.</p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>
<!-- End Page 4-->

<h3>This content will be ignored as well.</h3>

</body>
</html>

To load the new page, simply add a link to it in the markup for the third page of our
application:
<!-- begin third page -->
<section id="page3" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>Third page!</p>
<p><a href="external.html">Go to external page</a></p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>
<!-- end third page -->

This will produce the screen shown in Figure 2-4 on the third page of our application.

Pages | 13
www.it-ebooks.info

Figure 2-4. Link to external page

And when we tap the “Go to external page” link, jQuery Mobile will display the loading
dialog and attempt to fetch and insert the external.html page. If it succeeds, it will
display the page shown in Figure 2-5.
And it now becomes a part of the application and can be accessed from any other page
as if it were included in the original DOM.

When creating pages that will be loaded asynchronously, make sure you
do not introduce duplicate IDs into the original DOM.

Overriding Asynchronous Page Fetching


Sometimes you will want to actually load a page normally, rather than having jQuery
Mobile fetch it asynchronously and integrate it into the current DOM. You can override
the AJAX loading in two ways: specifying a target attribute on a link (such as
"_blank") or by specifying a rel="external" attribute on the link.

14 | Chapter 2: Application Structure and Navigation


www.it-ebooks.info

Figure 2-5. External page

Under The Hood: Page Initialization in jQuery Mobile


As jQuery Mobile initializes, it runs through the following steps:
1. Triggers the beforecreate event (see “Initialization Events” on page 83 in Chap-
ter 5 for more information)
2. Adds the ui-page class to all page elements
3. Adds the ui-nojs class to all page elements that had data-role="none" or data-
role="nojs" applied to them
4. Looks for child elements that have a data- attribute and:
a. Adds theming classes
b. Adds appropriate ARIA role and aria-level attributes
c. Adds a back button to the header (if there isn’t one already in the markup) for
pages beyond the first
5. Then it enhances form controls, buttons, and control groups (see Chapter 3 for
more information on these individual elements)
6. Finally, it fixes toolbars as specified (see “Positioning the Header and
Footer” on page 43 in Chapter 3 for details)
All of these enhancements are done within the page widget, and it transforms the orig-
inal markup shown in Example 2-3 into the enhanced markup shown in Example 2-4.

Pages | 15
www.it-ebooks.info

Example 2-3. Page markup before jQuery Mobile initialization


<!-- begin first page -->
<section id="page1" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content">
<p>First page!</p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>
<!-- end first page -->

Example 2-4. Page markup after jQuery Mobile initialization


<!-- begin first page -->
<section class="ui-page ui-body-c ui-page-active"
data-url="page1"
id="page1"
data-role="page">
<header role="banner"
class="ui-bar-a ui-header"
data-role="header">
<h1 aria-level="1"
role="heading"
tabindex="0"
class="ui-title">Header</h1>
</header>
<div role="main" data-role="content" class="ui-content">
<p>First page!</p>
</div>
<footer role="contentinfo"
class="ui-bar-a ui-footer"
data-role="footer">
<h1 aria-level="1"
role="heading"
tabindex="0"
class="ui-title">Footer</h1>
</footer>
</section>
<!-- end first page -->

Notice that the semantics of the markup hasn’t changed, all that happened was the
addition of ARIA attributes and CSS classes. Other more complex interface elements
(like list views) are more heavily enhanced, and jQuery Mobile will even modify
markup, usually by adding span or div tags.
It’s often useful to examine the alterations jQuery Mobile makes to your markup.
Unfortunately, most browsers limit their source view capabilities to just showing the
markup that was downloaded from the server, without any changes that might have
been made subsequently by JavaScript. Fortunately, most browsers have “view gener-
ated source” plug-ins or extensions. Firebug for Firefox, for example, has a view gen-
erated source capability, and there are similar extensions for Safari.

16 | Chapter 2: Application Structure and Navigation


www.it-ebooks.info

Page Hide and Show Events


Because of its asynchronous nature, jQuery Mobile makes the distinction between page
load events and page show and hide events. Page load events happen when a file is
loaded into the browser in a standard synchronous way. When a file is loaded like this,
the usual jQuery(document).ready() method is available for use, and jQuery Mobile
also fires off other initialization events as well (these will be covered in Chapter 4).
As we have seen, a single HTML file may contain multiple jQuery Mobile page views,
and the user can transition between those page views multiple times. These transitions
do not fire off the page load events, instead jQuery Mobile provides a set of events that
happen every time a page transition occurs. Each of these events provides references to
the event and ui objects:
pagebeforehide
This event fires on the page being transitioned from, before the transition starts.
Download from Wow! eBook <www.wowebook.com>

ui.nextPage will be either the page being transitioned to, or an empty jQuery object
if there is none.
pagebeforeshow
This event fires on the page being transitioned to, before the transition starts.
ui.prevPage will be the page being transitioned from, or an empty jQuery object if
there is none.
pagehide
This event fires on the page being transitioned from, after the transition finishes.
ui.nextPage will be the jQuery object of the page being transitioned to, or empty
if it does not exist.
pageshow
This event fires on the page being transitioned to, after the transition finishes.
ui.prevPage will contain the jQuery object of the page being transitioned from, or
empty if it does not exist.
These four events provide useful analogs to the jQuery(document).ready() call for
application page views.
To use these events, you attach event listeners to the appropriate page using
jQuery.bind(), jQuery.live(), or jQuery.delegate().

jQuery.bind(), jQuery.live(), and jQuery.delegate() are the different


methods that jQuery has for binding handlers to event listeners. For
more details, consult the jQuery documentation. Here we are using
jQuery.bind():
<script>
$("#page1").bind("pagehide", function(event, ui) {
var strAlert = "";
for (var thing in event) {
strAlert += thing + " : " + event[thing] + "\n";

Pages | 17
www.it-ebooks.info

}
alert(strAlert);
});
</script>

For pages that are all contained within the same document, jQuery.bind() is sufficient.
For pages that will be asynchronously loaded by jQuery Mobile, use jQuery.dele
gate() or jQuery.live().

When building a jQuery application, it is common practice to bind your


event handlers on document load. You can do something similar using
jQuery Mobile’s page hide and show events, but be careful. Since the
page hide and show events are triggered every time a page transition
happens, you might bind the event handlers more than once. For
example, if you bind a click event listener to an element within a page
show event, that click event listener will be bound every time that page
is shown. If you are only using that page once, that’s fine, but if the user
goes to that page multiple times, then the event listener will be bound
multiple times.
To get around this problem, you can either check to see if you have
already bound the event handler (and if you have, do not bind it again),
or clear the binding each time before you rebind. If you use the latter
method, namespacing your bindings can be particularly useful. For
more information on namespaced events, see http://docs.jquery.com/
Namespaced_Events. Namespaced events is a useful tool to have in your
jQuery toolbox.

Under The Hood: A jQuery Mobile Page Initialization Pattern


Consider the markup shown in Example 2-5 for a set of mobile application pages.
Example 2-5. jqmTwit
<!-- begin first page -->
<section id="page1" data-role="page">
<header data-role="header">
<h1>jqmTwit</h1>
</header>
<div data-role="content" class="content">
<p>Twitter feed goes here.</p>
<p><a href="#page2">Settings</a></p>
</div>
<footer data-role="footer">
<h2>Because the world needed another Twitter app.</h2>
</footer>
</section>
<!-- end first page -->

<!-- Begin second page -->


<section id="page2" data-role="page">

18 | Chapter 2: Application Structure and Navigation


www.it-ebooks.info

<header data-role="header">
<h1>jqmTwit: Settings</h1>
</header>
<div data-role="content" class="content">
<p>Settings go here.</p>
</div>
<footer data-role="footer">
<h2>Because the world needed another Twitter app.</h2>
</footer>
</section>
<!-- end second page -->

When the user first fires up the app, you’ll need to fill in the twitter feed. If the user
goes to the settings page, you’ll need to refresh the twitter feed when they return to the
main page. So you’d end up with some JavaScript, as shown in Example 2-6 .
Example 2-6. jqmTwit initialization script
<script>
$(document).ready(function() {

// Refresh the feed on first load


// (pretend we've written this function elsewhere)
refreshFeed();

$("#page1").bind("pageshow", function(event, ui) {


// Refresh the feed on subsequent page shows
refreshFeed();
})
})
</script>

This is a very simple example and is missing a lot of detail, but it does show the begin-
nings of a useful jQuery Mobile page initialization pattern:
1. Upon document ready, initialize anything that needs to happen on the first page,
plus any event listeners for elements throughout the application
2. Bind pageshow and pagehide events to pages as needed to handle transitions to and
from them.
This simple pattern works well and is extensible for complicated applications. It’s also
easy to wrap in the jQuery plug-in pattern (see “Under The Hood: Using Swipe Events
to Trigger Page Transitions” on page 81 in Chapter 5 for a full example of using the
jQuery plug-in pattern to create an application initialization plug-in). The only thing
to watch out for is to make sure your application can handle it if the user hits the refresh
button. The easiest way to do this is to make sure that the initialization events that fire
on document ready make sure that an expected view is being shown in an expected
state.

Pages | 19
www.it-ebooks.info

Dialogs
Any valid jQuery Mobile page can also be displayed as a dialog by simply adding the
data-rel="dialog" attribute to the link, as shown in Example 2-7. This signals jQuery
Mobile to add extra styles to the page when it is displayed, such as rounded corners,
margins, and drop shadows, so that it appears to be hovering over the rest of the
application.
Example 2-7. Calling a dialog
<!-- begin first page -->
<section id="page1" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>First page!</p>
<p><a href="#page2" data-rel="dialog">Open page 2 as a dialog</a></p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>
<!-- end first page -->

<!-- Begin second page -->


<section id="page2" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>Second page!</p>
</div>
<foote data-role="footer"r><h1>O'Reilly</h1></footer>
</section>
<!-- end second page -->

Tapping on this link will result in page 2 being displayed as a modal dialog, as shown
in Figure 2-6.

Navigation and History


jQuery Mobile automatically manages the URLs of the various pages and dialogs in the
application. Each page (that is to say, each element that has a data-role="page" attrib-
ute) will have its own unique URL within the application, allowing for bookmarking
and deep linking into your application. The URL for each page is stored in the data-
url attribute which jQuery Mobile attaches to each page’s containing element.
As the user moves through the application by tapping on links and buttons, jQuery
Mobile updates the location.hash object, allowing the framework to use the browser’s
native history capabilities to store the navigation information.

20 | Chapter 2: Application Structure and Navigation


www.it-ebooks.info

Figure 2-6. Page 2 as a dialog

Due to their modal nature, dialogs are not included in the history hash.

As a result, when you need to manually move from page to page in the application, you
will need to use jQuery Mobile’s changePage() method, so that the framework can
correctly handle everything:
changePage(to, transition, back, changeHash)
• to: one of the following:
— a simple string denoting either an element ID or a filename
— an array of two elements, with the first being a simple string denoting the ele-
ment ID or filename of the page to transition from, and the second being a simple
string denoting the page to transition to
— an object with the following properties:
— url: the url string of the desired page
— type: the HTTP verb (“GET” or “POST”)
— data: serialized parameters to send to the url
• transition: the name of the desired transition

Navigation and History | 21


www.it-ebooks.info

• back: a Boolean indicating whether or not the transition should be in reverse


• changeHash: a Boolean indicating whether or not the location.hash should be
updated upon successful transition
changePage gives you direct access to the framework’s page management system so that
you can perform more complex event-based paging, as shown in Example 2-8.
Example 2-8. Example uses of changePage
<script>
// Go to #page2 when .back-button is clicked, show animation in reverse,
// and do not update the location hash.
$(".back-button").bind("click", function() {
changePage("#page2", "flip", true, false);
});

// using changePage to submit a form


$("#my-form").bind("submit", function() {
if (validateFormData()) {
changePage({
url: "form-processor.php",
type: "post",
data: myFormData
}, false);
}
});
</script>

Transitions
jQuery Mobile has several animated transitions that can be used when changing pages
or displaying dialogs. These transitions are created using CSS 3 transforms, and so are
only available on browsers that support that feature.
To specify a transition, apply the data-transition property to the link, as shown in
Example 2-9. Valid values are:
fade: simply fade the page or dialog in over the previous content
flip: an animated page flip, rotating the current view out with the other view on the
reverse side
pop: the page springs into view from the center of the screen
slide: slide in from the left or right, pushing previous content out of the way
slidedown: slide down from the top, over the top of the current content
slideup: slide up to the top, revealing the next content below

22 | Chapter 2: Application Structure and Navigation


www.it-ebooks.info

Example 2-9. Specifying a transition for a dialog


<!-- begin first page -->
<section id="page1" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>First page!</p>
<p><a href="#page2"
data-rel="dialog"
data-transition="slidedown">Open page 2 as a dialog</a></p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>
<!-- end first page -->

As shown in Example 2-10, each transition can be reversed by specifying the data-
direction="reverse" property, though this is more useful for some transitions (slide
and flip, for example) than others (fade and pop, for example). jQuery Mobile will try
to employ the reverse transition in certain cases, such as when using the automatic back
button, or when hiding a dialog.
Example 2-10. Specifying reverse transitions
<!-- begin first page -->
<section id="page1" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>First page!</p>
<p><a href="#page2" data-transition="flip">Flip to Page 2</a></p>
</div>
<footer data-role="footer"><h1>O'Reilly</h1></footer>
</section>
<!-- end first page -->

<!-- Begin second page -->


<section id="page2" data-role="page">
<header data-role="header"><h1>jQuery Mobile</h1></header>
<div data-role="content" class="content">
<p>Second page!</p>
<p><a href="#page1" data-transition="flip" data-direction="reverse">Flip back to Page 1</a></p>
</div>
<foote data-role="footer"r><h1>O'Reilly</h1></footer>
</section>
<!-- end second page -->

Under The Hood: Animations in a jQuery Mobile Application


jQuery Mobile makes use of CSS 3 transforms for animating the page transitions. As
of this writing, jQuery Mobile uses webkit transforms, so they only work in webkit-
based browsers. The good news is that webkit browsers use hardware acceleration to
produce CSS animation, so the animations look smooth even on mobile devices.

Transitions | 23
www.it-ebooks.info

The transitions are defined as rules within the jQuery Mobile style sheet, and you can
use them directly if you wish to animate elements in your application beyond the page
transitions that jQuery Mobile provides. It’s a simple matter of toggling CSS classes,
as shown in Example 2-11.
Example 2-11. Animations in jQuery Mobile
<!-- begin first page -->
<section id="page1" data-role="page">
<header data-role="header">
<h1>CSS 3 Animations</h1>
</header>
<div data-role="content" class="content">
<p class="show-menu">Show/Hide Menu</p>
<div class="sliding-menu slide out">Menu</div>
</div>
<footer data-role="footer">
<h2>jQuery Mobile</h2>
</footer>
</section>
<!-- end first page -->

<script>
$(document).ready(function() {
$(".show-menu").click(function() {
$(".sliding-menu").toggleClass("reverse out in");
})
})
</script>

When you click on the Show/Hide Menu paragraph, the menu element will be animated
onto or off of the screen.
There are seven CSS classes that define base animations: slide, slideup, slidedown,
spin, fade, flip, and pop. In concert with these are the styles reverse, in, and out. By
combining these styles, you can animate elements in your application. You’ll need to
experiment to get the desired effects.
One word of warning: animations are nifty, but they can negatively impact usability
and accessibility. Use them judiciously.

24 | Chapter 2: Application Structure and Navigation


www.it-ebooks.info

CHAPTER 3
Page Elements

Like jQuery UI, jQuery Mobile has many different UI elements. Many of these are based
on common mobile UI elements, and are created in the standard jQuery Mobile way:
you write semantic markup and then apply a data attribute to the element, and jQuery
Mobile enhances the element upon initialization.

Under The Hood: jQuery Plug-ins and Widgets


jQuery Mobile makes extensive use of two standard jQuery development patterns: the
plug-in and the widget.
The jQuery plug-in pattern is a way of extending jQuery itself, enabling you to add
custom methods. You can then call your custom method just like you would any other
jQuery method. The jQuery plug-in pattern is discussed in detail in the jQuery docu-
mentation. If you’re not familiar with the jQuery plug-in pattern, I highly recommend
you read about it and adopt it whenever it is appropriate. I use the jQuery plug-in
pattern on a daily basis in my development tasks, and in the context of a jQuery Mobile
application, it provides a handy way of encapsulating application and page initialization
functions and data managers.
The jQuery widget pattern is slightly more complicated than the jQuery plug-in pattern,
but it is also more powerful. A jQuery widget is created using the jQuery.widget factory,
and like a plug-in, it results in a jQuery method that can be called on any selector. One
of the main benefits of using the widget factory is that it can maintain state even after
the resulting method is done executing, and the factory will enable garbage collection
to avoid memory leaks in browsers.
For example, consider the jQuery UI Accordion widget, which is a favorite of mine. To
create an accordion, you write your markup and then apply the jQuery.accordion()
method to it. During the initialization process, the accordion widget enhances the
markup, creates events that you can bind to, and exposes methods you can use to
interact with and modify the resulting accordion.

25
www.it-ebooks.info

Sound familiar? It should, that’s exactly what jQuery Mobile does. Many of the page
elements we are about to explore are created as jQuery widgets, and you handle them
in exactly the same way.

List Views
jQuery Mobile can produce visually formatted lists that are very similar to the styles
seen in native applications.

Basic List View


jQuery Mobile can enhance either an ordered or unordered list. Just apply the data-
role="listview" to a list, and jQuery Mobile will do the rest (Example 3-1, Figure 3-1).

Example 3-1. Basic list view


<h3>Unordered List</h3>
<ul data-role="listview">
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
<h3>Ordered List</h3>
<ol data-role="listview">
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ol>

List View Buttons


By default, list view elements have no interactive properties: tapping or swiping on
them has no effect. A common use of list views in mobile user interfaces is to have the
list items be tappable buttons. To do this with jQuery Mobile, you have to include
anchor tags in the list item markup (Example 3-2).
Example 3-2. List view with buttons
<h3>Unordered List</h3>
<ul data-role="listview">
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
</ul>
<h3>Ordered List</h3>
<ol data-role="listview">
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
</ol>

26 | Chapter 3: Page Elements


www.it-ebooks.info

The list items are now tappable (see Figure 3-2). (In this example, of course, these items
don’t go anywhere; keep reading for a more fully functional example.)
Download from Wow! eBook <www.wowebook.com>

Figure 3-1. Basic list view

Figure 3-2. List view with buttons

List Views | 27
www.it-ebooks.info

List View Dividers


It’s very common to want to have your lists divided by section headers. To do this with
jQuery Moble, apply the data-role="list-divider" to any list item you want to be a
divider, as shown in Example 3-3. Figure 3-3 shows the result.
Example 3-3. List view with dividers
<h3>Unordered List</h3>
<ul data-role="listview">
<li data-role="divider">Things</li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li data-role="divider">Stuff</li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li data-role="divider">Miscellaneous</li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
</ul>
<h3>Ordered List</h3>
<ol data-role="listview">
<li data-role="divider">Group</li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li data-role="divider">Group</li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li data-role="divider">Group</li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
<li><a href="#">Item</a></li>
</ol>

28 | Chapter 3: Page Elements


www.it-ebooks.info

Figure 3-3. List view with dividers

Advanced List Views


Because list views are used widely in mobile user interfaces, jQuery Mobile can produce
several of the common variations with just a little more markup.

Nested Lists
jQuery Mobile will take nested lists and produce interactive views into which the user
can drill down by tapping on individual items. The first view will consist of the items
in the top-level list, and tapping on one of those items will display its sub-list, and so
forth. The code for this is shown in Example 3-4; the resulting linked list views are
shown in Figures 3-4, 3-5, and 3-6. jQuery Mobile will automatically provide a back
button and manage the URL mapping and transitions from page to page.

List Views | 29
Another Random Document on
Scribd Without Any Related Topics
fidelity to Basiliscus that the clergy could devise, he straightway sold
his services to Zeno for the promise of a cæsarship for his son and
the perpetual command of the armies for himself.
The career of the romantic Zenonis then came to a rapid and
tragic close. As the troops of Zeno marched into the city Basiliscus
and his Empress fled to the church of St Sophia, and endeavoured,
by promises of undoing their heretical work, to induce the clergy to
make Zeno respect the sanctuary. After a time an imperial officer
came to the trembling wretches by the altar, and stripped them of all
their imperial ensigns, to be taken to Zeno and Ariadne. Zeno
scrupled to drag them from the altar, and they were at last induced
to come forth on the solemn assurance that their lives would be
spared. It was now their turn to sail for Asia. They were sent to an
obscure village in Cappadocia, and imprisoned in a tower. One
tradition reports that they were killed on the journey, but the more
persistent and convincing report is that the door of the tower was
sealed with masonry, and the brother of Verina and his Empress
were doomed to a slow and horrible death by starvation. It was the
second revolution in three years, and Verina had been an active
element in both.
Exile had not improved the temper of Zeno, and the restoration
of his rule was at once stained with murder. He reflected gloomily on
the prestige of the handsome Harmatius, and easily persuaded
himself that he who had been faithless to one master might be
faithless to another. Soon afterwards the luxurious officer was cut to
pieces as he ascended the spiral stair from the palace to the
Hippodrome; his son was stripped of the robes and ensigns of Cæsar
and was sent to take a minor order of the Church at Blachernæ. But
for the intervention of the more humane Ariadne the youth would,
like his father, have exchanged his high dignity for death.
Constantinople seems to have regarded the murder with
indifference, but an avenger arose in the provinces and the two
Empresses had soon grave cause for anxiety. For a time
Constantinople trembled under the menace of the formidable
barbarians, but they at length returned to Italy without having
penetrated into the city. A more serious danger fell upon the palace
in the following year, however, when the younger daughter of Verina
joined for a moment in the conflict of ambitions. Leontia, it will be
remembered, had married Marcian, son of the Western Emperor
Anthemius. On the ground that she had been “born in the Porphyry,”
while her elder sister Ariadne had been born before the crowning of
Leo, her husband demanded that the Empire should be assigned to
him, and marched on Constantinople at the head of an army. He
broke through the defences of the city, and some of the chroniclers
actually assure us that he surprised the guard of the palace in their
midday siesta. It is at least certain that Zeno and the Empresses fled
in alarm, and a vigorous action would have put Verina’s younger
daughter on the throne. Marcian seems, however, to have postponed
the occupation of the palace until the following day, and the
commander Illus, secretly transporting fresh troops from Asia,
restored the balance in favour of Zeno and Verina. Marcian was
visited with the more refined punishment of the Byzantine world—he
was forced to enter the priesthood—and Leontia retired into
obscurity.
But the romance of Verina and her daughters had already
entered upon a fresh chapter. Verina had welcomed her returning
son-in-law at the palace, and her earlier expulsion of him and
Ariadne was overlooked in view of the important share she had had
in securing their return. We can, however, well understand that Zeno
regarded her with suspicion and distrust, and would welcome the
first opportunity to remove her from the palace. The argument which
he had applied so remorselessly to Harmatius plainly extended to his
imperial mother-in-law. The writers of the time represent him as not
taking a prominent part in the events that followed, but it is difficult
to doubt that his secret commands directed the whole intrigue.
In the year 478 a soldier attempted to assassinate the
commander Illus, and he confessed—under torture or bribery—that
he had been instructed by Verina’s steward Epinicius. The steward
was given into the custody of Illus by the Emperor, and was sent
under guard to a castle in Isauria. Illus followed, and easily induced
the steward to impeach his mistress. Illus then returned to the city,
and arranged with Zeno a plot for the capture of Verina. It is clear
that the Empress-Mother had great power in Constantinople, and
that they dare not openly touch her. Illus was to go to Isauria, and
pretend that he feared danger from Zeno. The Emperor was then to
ask Verina to take to Illus with her own hand a letter of indemnity,
and, when she reached Isauria, she was to be imprisoned there. We
should find it difficult to believe that so naïve a plot could entrap the
virile and experienced Empress were we not expressly assured of it
by the highest authorities. In a few weeks Verina was enraged to
find herself imprisoned in a Papirian fortress, one of the strongly
fortified castles of remote Isauria. One authority observes that they
first compelled her to take the vows of a nun, but we may decline to
believe that they troubled to place so frail and so superfluous a chain
on such a woman.
From the lonely hills of Isauria Verina at length found a means of
communicating with Ariadne and securing her interest. Zeno, to
whom Ariadne appealed, referred her to Illus, and, when that
general was summoned to the Empress’s apartments, and implored
with tears to release her mother, he bluntly asked: “Do you want to
be rid of your husband and wed another?” Ariadne returned stormily
to her husband, and declared that either Illus or she must leave the
palace. “If you can do anything, I’m with you,” said the distracted
Emperor, who was overshadowed by the vigorous commander.
Presently, as Illus was mounting the spiral stair to the Hippodrome, a
soldier in the pay of Ariadne’s chamberlain fell upon him. Illus was
saved, except for the loss of an ear, by his guards, but he prudently
decided that Constantinople was injurious to his health and
requested the Emperor for a change of air. He was appointed
commander of the eastern troops, took with him the patrician
Leontius and a distinguished company, and reached Antioch only to
declare himself in rebellion and Leontius Emperor.
In the extraordinary confusion of events which the meagre
chronicles transmit to us Verina had obtained her wish in an
unexpected manner. A messenger came to her in her solitary prison
to say that she was to crown Leontius at the city of Tarsus and join
forces with him and Illus against Zeno. Verina was not the woman to
hesitate. She crowned Leontius, a cultivated Syrian noble and
excellent soldier, at Tarsus, and issued a characteristic letter to the
officials and commanders of the Empire:

“Verina Augusta, greeting to our prefects and Christian


peoples. You know that the Empire is ours, and that after the
death of our husband Leo we, trusting to improve the
condition of the commonwealth, raised to the throne
Trascallisseus, who was afterwards called Zeno; now,
however, since we perceive that he is deteriorating, and on
account of his insatiable avarice, we have thought it needful
to give you a Christian Emperor, adorned with piety and
justice, that he may save the commonwealth and administer
war with moderation and prudence. We have therefore
bestowed the imperial crown on Leontius, most pious of
Romans, who will guard us all with care and prudence.”

The throne of Leontius was set up at Antioch, and the aged


Empress turned with her confederates to face Zeno’s troops. It was
to be the last act of the stirring drama of her life. Zeno acted with
unaccustomed vigour, and in a few days Verina and her companions
were flying to Isauria. They shut themselves in the Papirian fortress
and prepared to sustain a long siege. In the middle of the siege
Verina died, and was spared the humiliation of the final defeat. Four
years afterwards the heads of Illus and Leontius were exhibited on
poles at Constantinople, but the body of Verina was decently
interred there by her daughter.
The loss of contemporary historians prevents us from obtaining
the closer acquaintance with Verina which her romantic story leads
us to desire. Of her personal appearance and nationality we know
nothing. One is tempted to conceive her as a Syrian woman of the
type of Zenobia or Julia Domna: a virile and masterful personality,
ambitious and unscrupulous, subtle and astute rather than
cultivated, paying no more than a merely external and superficial
regard to the teaching of the new religion of the Roman world. It
remains to say a few words about the Empress Ariadne before we
consider the next great Empress of the Byzantine world.
In the few peaceful years which followed the death of Verina life
at the palace became sombre and painful. Zeno was morose,
suspicious and unpopular, and increased the gloom by the usual
device of executing, or murdering, suspects. Their only son came to
a lamentable end. The officials in charge of his education felt that it
would be more profitable to themselves to teach him vice and luxury
rather than the manly arts which his parents required, and he was
profoundly corrupted. His ostentatious vanity invited ridicule, and his
indulgence in unnatural vice and intemperance ruined his
constitution. He fell an early victim to dysentery, and his father
plunged into deeper bitterness amid the splendours and pleasures of
his palace. Ariadne must have awaited the end with impatience, and
it is not improbable that she already chose a partner to share her
throne. Popular rumour afterwards said that she buried Zeno alive. It
was said that he used to fall into a kind of trance after his gluttonous
meals, and that Ariadne in disgust bade the servants seal him in a
tomb; the legend even represents him as recovering and crying in
vain to be relieved, and one version pretends that, when the tomb
was eventually opened, he was found to have eaten his boots and
belt. The truth seems to be that he was subject to epileptic fits, one
of which ended his life in April 491.
Ariadne at once nominated for the Empire a peasant of northern
Greece who had a very subordinate position in the military service of
the palace. A tall, handsome man—though one of his eyes was grey
and the other almost black—of strong, quiet character, he seems to
have been chosen by Ariadne as her future husband before Zeno
died. He was unmarried, though past middle age. One of Ariadne’s
eunuchs secured the consent of the Senators to the strange
nomination, and Anastasius obtained the applause of the people by
remitting their debts to the treasury. The only opposition came from
the patriarch, or archbishop, who had in earlier years been
compelled to prevent Anastasius from setting up an unofficial pulpit
in the streets of the city and teaching his favourite heresy.
Anastasius genially forswore his heresy for so high a price, was at
once crowned Emperor, and married Ariadne on the fortieth day
after the burial of Zeno. Docile and clinging as Ariadne had been in
her earlier years, she fully reveals herself as the daughter of Verina
in her middle life. But the twenty-five years of life which remained
for her are years of obscurity, as far as the Empress is concerned,
and we will not linger over them. Storm after storm broke over the
palace, where she lived, but she seems to have taken no part in
public events. The Isaurians marched on the city to demand the
throne for the brother of Zeno, and a long struggle ended in the
complete destruction of the power of the Isaurians. Then Anastasius
returned to his Monophysite heresy, and the streets of the city and
towns of the Empire rang with defiance and anathema. On one
occasion, in 512, the mob burned the monasteries which Anastasius
favoured, and so angrily assailed the palace that the ships were
made ready at the quays to conduct Ariadne and her husband to
Asia. Anastasius had been guilty of the additional indiscretion of
attempting to reform the morals of Constantinople and forbidding
5
contests with wild beasts in the arena. Ariadne lived until the year
515 or 516, when she must have been about seventy years old. So
completely was she overshadowed by her second husband that the
only reference we find to her in the chronicles is that on one
occasion she begged Anastasius to make a certain appointment, and
he refused.
CHAPTER II

THE EARLY LIFE OF THEODORA

T
HE next Empress to occupy the superb apartments in the
palace, with their couches of ivory and silver and their
regiments of fawning eunuchs and silk-clad ladies, was
assuredly one of the most remarkable figures that ever sat on a
throne. The Empress Euphemia hardly ever issues into the pages of
history from the becoming seclusion of the women’s quarters in the
palace, but the few details which we have concerning her suggest
the most incongruous figure that imagination could place in such a
world, and a brief account of her romantic elevation is a necessary
introduction to the equally remarkable and better-known story of the
famous Empress Theodora. The Roman Empire seemed to be
deterred by some faint recollection of its early democratic spirit from
admitting the hereditary principle; but the absence of this
arrangement for securing the succession, together with the complete
lack of any really democratic arrangement, often threw it into a
chaotic confusion when a ruler died, and made its internal history a
thrilling succession of romances and tragedies, with an occasional
page of comedy. In this case it is comedy.

Anastasius, after playing his successive parts as peasant, lay


preacher, soldier and ruler of the world, had passed away, amid the
derision and rejoicing of his people, in the year 518. His nephews
had feeble pretensions to succeed him, but the most powerful man
in the city, the Prefect Amantius, decided that the purple should pass
to his friend Theocritus. He therefore sought the commander, or
Count, of the Excubitors—the more formidable guards of the palace
—and placed in his hands a large sum of money for distribution
among the troops. Justin, the said commander, was an Illyrian
peasant who had won promotion in the wars. He was in his later
sixties, though still a powerful man, with handsome rosy face and
curly white hair; but under this disarming exterior he concealed an
ambition and astuteness which the prefect failed to suspect. He
distributed the money in his own interest, and passed unopposed
from the modest quarters of the guard to the more luxurious
chambers of the palace.
Euphemia was the wife of Justin, and it may safely be said that
no woman ever experienced a more romantic elevation. In his
military days Justin had bought a barbaric slave named Lupicina, and
raised her to the rank of his concubine; though no doubt he married
her in the course of time. She retained the uncouth and illiterate
manners of her class, and Constantinople must have smiled to see
her in the richly embroidered robes of purple silk, with cascades of
diamonds and pearls falling from her gorgeous diadem. The
acclamation of the crowd changed her name to Euphemia, and she
retired to the congenial privacy of her palace. Justin brought his
equally illiterate mother Bigleniza to the palace from her rustic
home, and the two women no doubt contracted a fitting friendship
in their wonderful new home. Of public action on their part there is
no question, and the events of the next few years do not concern
us. I will say only that, after securing his throne by cutting off the
head of Amantius and crushing Theocritus under heavy stones in his
dungeon, for venturing to resent the trick he had played them,
Justin ruled with moderation, if not prudence, for nine years.
Euphemia died three or four years before him, living just long
enough to see, and emphatically resent, her successor, the notorious
Theodora.
In approaching the story of Theodora it is necessary to premise
a few words on the authority which has provided most of the
sensational statements about her, and to pay respectful attention to
the efforts of some recent historical writers to discredit those
statements. The general outline of her story has been made familiar
by Gibbon, who has genially dilated on the elevation of one of the
lewdest actresses and most notorious prostitutes of Constantinople
to the position, not merely of mistress of the greatest empire of the
time, but also of patroness of an important branch of the Church
and the daily companion of saintly monks and bishops. Since
Theodora is very commonly described by the chroniclers as at least
equal in power to her husband, the great Justinian, and since the
next most powerful woman in the Byzantine Empire at the time is
assigned a similar origin to that of Theodora, the world has long
reflected with amazement on this spectacle of the Roman Empire at
the feet of two imperfectly converted prostitutes. Such a situation
could not pass unchallenged before the more critical tribunal of
modern history, and there are scholars who have rejected entirely
6
the romantic story of the youth of Theodora. The majority of
historians, including the two chief living authorities, Professor Bury
and M. Diehl, regard the story as true in substance though unreliable
in detail.
The more romantic statements concerning Theodora are taken
from a work that purports to have been written by the greatest
contemporary historical writer, Procopius, but there are writers (such
as Ranke and Bury) who regard the work as, at the most, a later
compilation of notes left by Procopius, and in any case it is so
envenomed in temper, and occasionally so reckless in statement,
that it should be regarded with suspicion. The problem cannot be
discussed at length here, but it is necessary to justify the large use I
am about to make of the work (the “Anecdotes”) which bears the
name of Procopius.
If it were true, as is sometimes said, that we had no authority
for the impeachment of the character of Theodora beyond the
“Anecdotes,” we should have to hesitate very seriously, but this is by
no means true. Procopius (“On the Persian War”) represents her as
playing a most unscrupulous part in the ruin of John of Cappadocia.
Liberatus (a contemporary cleric) and Anastasius exhibit the Empress
to us corrupting the papacy itself and deposing a venerable pontiff
by the most cruel and flagrantly dishonest charges. Zonaras and
other writers accuse her, not merely of avarice, as Mr Mallett says,
but of the most heartless and unblushing corruption in feeding her
avarice. There is every reason to regard Theodora, after her
elevation to the throne, as a woman devoid of moral scruple. But we
now have ample confirmation also of the story of her origin. The
statement of an eleventh-century writer, Aimoinus, that Justinian
took his wife from a brothel, shows, in spite of its wild inaccuracies,
that some such tradition was found in European literature quite
apart from the “Anecdotes.” But the publication in the nineteenth
century of the writings of John, Bishop of Ephesus, has furnished a
decisive proof. This Monophysite bishop and cultivated writer, who
lived for years beside the palace of Theodora, and whose sect
received the most imperial and incalculable benefits from her, speaks
of her as “Theodora of the brothel”; and he uses the phrase in such
a way as to intimate plainly that this was the name by which she
7
was known in Constantinople before her elevation to the throne.
Indeed, the fact that the author of the “Anecdotes” does not assail
the chastity of Theodora after her marriage increases our confidence
in his account of her earlier life; as he did not intend to publish his
work—it was not published until 1623—it would have been just as
easy to invent or collect legends about her after as before her
marriage. On the other hand, the temper of the writer is so bitter
and malignant that we must reserve our judgment in regard to the
details of his strange narrative. He has gathered together every
defaming rumour about Theodora and Justinian that circulated in
Constantinople, even admitting nonsense obviously unworthy of a
serious writer, and we cannot sift the true from the legendary. The
source of his animosity cannot be determined. From the tone of his
remarks on religion I gather that he was one of the many surviving
pagans who were forced into outward conformity with the new
religion, and, after giving formal praise in his historical works to
Justinian and Theodora for the splendour of their reign, he relieved
his soul, in this secret collection of notes, of the deep disgust he felt
at the contrast between their characters and their professions and
between the glamour and the misery of their empire. It must be
remembered that the thoroughly Christian and very weighty
authority, Evagrius, is just as severe on Justinian; there was in
Justinian, he says, “something surpassing the cruelty of beasts,” and
any prostitute could despoil a wealthy man by a false charge (say, of
unnatural vice—a trick of Theodora’s) “provided she let Justinian
share her vile gain.” It is the common teaching of the authorities
that the Empress was worse than the Emperor.
In point of fact, there is nothing implausible or improbable in the
details of Procopius’s story of Theodora’s early life, and the judicious
reader will merely make allowance for the rhetorical strength of its
superlatives. Her father Acacius had been a keeper of the bears
which were baited in the Hippodrome in the reign of Anastasius. The
Hippodrome at Constantinople united the functions which at Rome
had been divided between the circus, the theatre and the
amphitheatre. Its chief attraction was the chariot-racing which
8
provided the central and most thrilling sensation of Roman life.
Between the races, however, there were contests with wild beasts in
the arena, and there were the numerous nondescript performances
which occupied the theatre at Rome—mimes (actors by gesture),
clowns, acrobats, conjurers, etc. Acacius was bear-keeper to the
“greens,” and, when he died, his widow promptly secured another
partner and claimed the office for him. But the superintendent
Asterius had sold the office to another man, and the shrewd widow
appealed to the sympathy of the crowd by parading in the
Hippodrome, the heads and hands of her three daughters crowned
with the emblems of virginity. The “greens” jeered—possibly at the
sight of the eldest daughter, Comitona, a loose girl of seventeen,
dressed as a Vestal Virgin—but the “blues” received them with
sympathy; a distinction which the pale and slender little Theodora
would never forget.
The mother, who is said to have come from Cyprus, either before
or after the birth of Theodora, then pressed the fortunes of her
daughters in the theatrical world. Comitona was already a mime (or
actress without words) and, as was usual, a prostitute. The young
Theodora presently began to attend her elder sister, and is said to
have begun her career of infamy as she waited among the slaves
and lackeys on the fringe of the Hippodrome. When she in turn
became an actress, her pretty pale face, lithe figure and
unrestrained gaiety and dissoluteness made her a great favourite.
She stripped to the narrowest limit of decency which the very liberal
law permitted, performed the most nearly obscene ribaldries which
the Roman theatre allowed, and was pre-eminent for the
abandonment of her gestures and movements; and in the hours of
the night, when the wealthier patrons of the Hippodrome
entertained themselves in perfumed chambers with the actresses
and courtesans, Theodora was in the greatest favour.
It is absurd to say that this is to impute to Theodora “a moral
turpitude unparalleled in any age.” It was the common turpitude of
that age, of our age, and of every intervening age. The theatre,
indeed, no longer admits the very broad licence which was admitted
at Constantinople, but the performances which are ascribed by
Procopius to Theodora are innocent in comparison with certain
performances which may be witnessed, in semi-publicity, in very
many cities of Europe to-day. Of Theodora’s private behaviour—that
she practised both forms of unnatural, as well as natural, vice—one
need only say that it is, and always has been, common to her class.
An actress at that time meant a woman of loose conduct. The
imperial decrees and the Church fully recognised this, and it is
significant that one of the theatres—if not the one theatre—of
Constantinople was called “The Harlots,” and is so named in an
imperial document. Procopius is merely imputing to Theodora the
common practices of loose women of her time and our own. And
when, in later pages, we come to realise the fiery and unrestrained
temper of the beautiful Greek, we can well believe that she was at
that time one of the worst of her class.
Not less plausible is the next chapter in the life of Theodora. A
wealthy official, Hecebolus, induced her to accompany him to the
African province which he was to administer, and her very brief
career at Constantinople came to a close. M. Diehl conjectures that
this occurred in 517, in her eighteenth year, and that she remained a
few years with Hecebolus. However that may be, she was, about the
year 521, ejected from the governor’s house, and she passed to
Alexandria, and thence to Antioch and the other cities of Syria and
Asia Minor. It is most probable that this was the time when, either at
Alexandria or Antioch, she became a convert to the Monophysite
faith. The question of the true character of Christ had racked and
rent the Eastern world, amidst all its ribaldry and vice, for two
hundred years, and the burning issue at this time was whether the
nature of Christ should be described as single or twofold; the
Monophysites held that there was but one nature in Christ, and were
bitterly opposed to the “Synodists,” or supporters of the orthodox
Council of Chalcedon. It may seem incongruous to drag in so solemn
an issue on so defiled a page of biography, but it is essential for the
understanding of Theodora’s career.
According to Procopius, Theodora still practised her evil
profession in the cities of Asia. For the next few years, however,
there is much obscurity about her movements, and the biographer
cannot proceed with great confidence. One eleventh-century writer
represents that Justinian and the commander Belisarius chose their
wives in a loose house in Constantinople; another equally remote
and unreliable chronicler says that Justinian found Theodora living a
modest life, supporting herself by spinning wool, in a small house
under the portico—a very strange residence for a virtuous woman. I
prefer still to follow the very plausible story (in substance) of the
“Anecdotes.” At Antioch Theodora went in great distress to visit
Macedonia, an actress who had influence with Justinian. It is hardly
strained to conjecture that this was the real occasion of her
introduction to Justinian; that she went on to Constantinople with a
recommendation to him and was at once taken into his house.
Beyond question she was his mistress for some years before he
married her.
Justin had brought from Upper Macedonia, and educated in the
schools of Constantinople, the favourite nephew who was to become
the Emperor Justinian. At the time when Theodora came back to
Constantinople, about the year 522, he approached his fortieth year:
a handsome, wealthy and free-living bachelor, of fresh and florid
complexion and the curly hair of a Greek. His reputation was
somewhat sinister: his influence unbounded. In entertaining the
populace on his elevation to the consulship in the previous year he
had spent about £160,000, and had turned twenty lions and thirty
leopards together into the arena. He was plainly marked for the
throne. The pretty pale face and bright eyes and graceful figure of
Theodora captivated him, and her experienced art enabled her to
profit by the infatuation. Justinian lived in the palace of Hormisdas
on the shore of the Sea of Marmora, and Constantinople would take
little scandal at his connexion with Theodora. Four or five years’
absence would have enfeebled the memory of her earlier career, and
the zeal for the true religion—the Monophysite heresy, which she
paraded from the moment of her connexion with Justinian—would
ensure the genial indulgence of the frivolous population. Justinian
had her made a “patrician” (or noble), lodged her in his beautiful
palace, and showered his favours upon her. It is at this point that
Bishop John begins to describe his co-religionists appealing to the
protection of “Theodora of the brothel” from all parts of the Empire.
There were two obstacles to marriage. Justin was feeble and
senile, and little able or disposed to resist his nephew’s whims, but
Euphemia strongly opposed the marriage until her death in 523 or
524. The more serious impediment was the standing law of the
Roman Empire, that a noble could not wed a woman of ill-fame (an
actress, tavern-girl or courtesan). Justinian afterwards removed this
restriction, but it must have been in some way overruled by Justin,
and many authorities believe that the first law in the Justinian Code
on the point was really promulgated by Justin. A daughter seems to
have been born before the marriage, possibly before the connexion
with Justinian, as John of Ephesus confirms the statement of
Procopius that Theodora had a marriageable grandson before she
died (in 548).
The next step for the enterprising young Greek was the
attainment of the throne. Justin was pressed, as he aged, to
associate his nephew in the government, and, although he nervously
refused for some time, he at length (April 527) conferred the
supreme dignity of Augustus on his nephew and of Augusta on
Theodora. She now entered upon the full splendour of imperial life,
and no parvenue ever bore it with more exaggerated dignity than
the ex-actress, as we shall see. There must have been many who
smiled when Theodora first witnessed the old sights of the
Hippodrome from the imperial chapel of St Stephen, or sat for the
homage of the Senators in the long gold-embroidered mantle, with
the screen of heavy jewels falling in chains from her diadem upon
her neck and breast, as we find her depicted in a mosaic at
Ravenna; but her formidable power and her unscrupulous use of it
would soon extinguish the last echo of her opprobrious nickname.
The early years of Theodora’s power were spent in enlarging the
prestige of her position and in recompensing her friends. The
existent palaces could not meet the requirements of the woman
who, a few years before, had begged money of an Antioch
courtesan. Justin had to annex his palace of Hormisdas to the
imperial domain and build fresh palaces. The favourite residence of
Theodora was the cool and superb palace of Hieria across the water,
and in spite of the lack of accommodation for her enormous suite
and the terrors of a whale, popularly named Porphirio, which
infested the waters of Constantinople at the time, she frequently
crossed to it.
At home, in the sacred palace, she led a life strangely opposed
to that of the temperate, accessible and hard-working Justinian.
Rising at an early hour she devoted a considerable time to the bath
and toilet, by which she trusted to sustain her charm, in spite of
delicate health. After breaking her fast, she again retired to rest
before she would consent to receive courtiers and suitors. In view of
her paramount influence with the Emperor many sought her
patronage, or dreaded to incur her terrible resentment, by seeming
indifferent to it. Numbers of nobles waited, sometimes for days, in
the hot ante-room to her apartments, standing on tiptoe to catch the
eye of the pampered eunuchs who passed to and fro. After a long
delay they might be admitted to kiss the golden sandals of
Theodora, and listen to her august wishes. No man was permitted to
speak except in reply to a question. In the course of time, as we
shall see, the highest nobles eagerly submitted to this humiliating
treatment, in order to preserve their wealth from the extortioner.
Dinner and supper, at which, though Theodora ate little, the most
opulent banquets had to be served, occupied the further hours of
the day, together with Theodora’s abundant devotions and converse
with holy men.
Her friends were generously admitted to share her advantages.
The “Anecdotes” tell a story of an illegitimate son of hers who
discovered his birth, came to the Empress for recognition or money,
and was at once despatched to another world. That seems to be one
of the calumnious fables which the writer too eagerly admitted into
his indictment. The “Anecdotes” themselves rather show that
Theodora did not make every effort to conceal the past, however
strongly she might resent discussion of it. Her sister Comitona was
certainly married in the first year of her reign to a wealthy and
powerful noble. It is not so certain, but probable enough, that she
cherished her earlier theatrical friends, Chrysomallo and Indara, and
found wealthy husbands for their daughters. The woman whose
name we shall find most closely connected with hers, Antonina, the
wife of the great general Belisarius, is said to have been her
tirewoman before she married Belisarius. This would account for
Theodora’s coolness until Antonina won her by securing her revenge
on John of Cappadocia, when Theodora is said not merely to have
overlooked, but promoted, the vices of her friend. There is, at least,
no room for doubt about the character of Antonina.
But while Theodora admitted these mute reminders of her earlier
life, she turned with extraordinary severity upon her earlier
colleagues as a body and undertook the purification of the city. The
decrees of Justinian for regulating the morals of Constantinople—
decrees which go so far as to define the penalties for people who
made assignations in churches, and on the strength of which bishops
were castrated and exhibited in public for unnatural vice—are
generally ascribed to her influence. She had the imperial net
dragged through the loose houses of Constantinople, and five
hundred of the occupants were imprisoned in an ancient palace on
the Asiatic shore: a form of enforced piety which, the carping
Procopius says, drove many of them to suicide. Many writers think
this zeal for purity inconsistent with the story of her earlier life. It
has rather the appearance of a feverish affectation of repentance,
and must be balanced by the many proofs we have of Theodora’s
really corrupt and unscrupulous character. One may recall that
Domitian drastically punished the vices of others. Procopius would
have us believe that Theodora compelled unmarried women to
marry, and that when two delicate widows fled to the Church to
escape her pressure, she had them dragged from the altar and
married to men of infamous life. Yet, he says, vice was rampant in
Constantinople, and protected by the Empress, when money was
paid into her greedy coffers. Such details we cannot control, and
must reproduce with reserve; we know only from other sources that
she extorted money by corrupt means.
And the most singular and piquant feature of Theodora’s life at
this period was her zealous patronage of the Monophysites. Long
before her coronation, from the time when she became the mistress
of Justinian, the joyous news of her elevation flew throughout the
Empire among the persecuted heretics. They had had their hours of
triumph under Basiliscus and Anastasius, but with the accession of
Justin the orthodox had returned to power, and the twofold nature of
the gentle Christ had been urged with bloody arguments. From the
monasteries and towns of the provinces pilgrims now began to arrive
at the Hormisdas palace in great numbers, and through Justinian
she obtained relief and money for them. When she entered the
imperial palace the procession increased, and, while the nobles of
Constantinople were detained for hours before being permitted to
kiss her feet, ragged monks and unlettered deacons strode into the
imperial apartments without a moment’s delay.
So zealous, indeed, was Theodora for their edifying conversation
that she kept them as long as possible about her. St Simeon of
Persia came to plead the cause of his persecuted brethren, and was
induced to live for a year in the luxurious palace. Arsenius of
Palestine, one of the chief firebrands of his province, was cherished
by her; though Procopius affirms that he at length lost her favour
and was crucified. Orthodox monks were even permitted with
impunity to rebuke the terrible Empress. A holy hermit came one day
to chide Theodora for her heresy. Ragged and dirty, with garment so
patched that hardly three inches of cloth of one colour appeared in
it, he admonished her in fiery language. Theodora was so charmed
with his piety that she sought to add him to her domestic collection
of sanctities. When persuasion failed, she resorted to corruption; we
read the story, not in the “Anecdotes,” but in John. She had a large
sum of gold concealed in linen and imposed on him, but the fiery
monk hurled it across the palace, crying: “Thy money perish with
thee.” St Sabas, also, the unlettered and unadorned abbot of an
orthodox monastery at Jerusalem, came to ask her patronage. His
piety excused his heresy in her eyes, and she kept him for days at
the palace, and humbly asked his prayers that she might have a son.
The grim monk refused, and, when companions asked how he could
scorn the request of so generous a patroness, he replied: “We do
not want any fruit from that womb, lest it be suckled on the heretical
doctrines of Severus.”
So great at length became the number of pious pilgrims from
the provinces, and so eager was Theodora to retain them near her
person, that the Hormisdas palace, which Justinian had richly
decorated for her and enclosed within the area of the imperial
palace, was converted into a monastery. Then were witnessed the
quaintest scenes that ever enlivened the passion-throbbing palace of
the Eastern Emperors. Five hundred monks, of all ages and
nationalities, of every degree of sanctity and raggedness, were
crowded in or about its marbled walls. Every form that monastic
fervour had assumed in the fiery provinces of Syria or Egypt was
exemplified in it. The orderly community sang its endless psalms and
macerated its flesh in the rooms where Justinian had dallied with his
mistress: little huts were scattered about the grounds for those who
were called to the life of the hermit: and even columns were set up
here and there for those who would imitate the more novel and
arduous piety of St Simeon Stylites, and pass, at the open summit of
the column, a kind of existence which the polite pen must refrain
from describing. All the beggars of Constantinople gathered for the
crumbs of this remarkable colony, and crowds of citizens pressed to
witness this singular oasis of virtue in the most corrupt city of the
world. Theodora rarely let a day pass without crossing the gardens
to receive the blessing and enjoy the pious conversation of such of
the saints as would deign to converse with a woman.
How she went on to put a courtly heretic upon the
archiepiscopal throne of Constantinople, and, by an extraordinary
piece of intrigue and corruption, depose a pope and replace him by
one who pretended to favour her designs, we shall see presently. We
must now set forth the imperial career of Theodora in chronological
order, and learn what kind of character this remarkable woman
maintained amid the chants and prayers of her deeply venerated
monks.
CHAPTER III

THE EMPRESS THEODORA

W
E have seen how Theodora rewarded the friends, and must
now see how she punished the enemies, of her earlier
career. It will be remembered that her father had been a
servant of the “greens” of the Hippodrome, but that this party had
greeted her mother with derision when she appealed for sympathy
with her three children, while the “blues” received them
compassionately. Twenty years afterwards the young circus-girl had
become the most powerful woman in the world, and the blues began
to tyrannize with impunity over their rivals. In the earliest years of
the reign of Theodora and Justinian we find them swollen with
conceit and encouraged in the perpetration of every kind of disorder.
The livelier “sparks” of that faction advertised their formidable
character by adopting the trousers and sandals of the fierce Huns
and trimming their hair after the fashion of those terrible invaders;
they wore long moustaches and beards, shaved the front part of the
head, and cultivated long hair at the back.

A few outrages soon taught them that the laws would not be
enforced against them, and before long the city of Constantinople
became, during the night, a land of terror. The citizen who dared to
pass along the streets with a gold clasp to his belt or his cloak or
money in his purse was robbed, and women could not move after
nightfall. The continued silence of the authorities encouraged the
blues, and drew all the dissolute elements of the city into their
ranks. They now began to force the doors of the houses, plunder the
coffers, rape the wives and daughters, and carry off the more
handsome slaves and boys. At the least resistance their deadly
poniards were drawn, and murder became frequent. When the
authorities intervened, none but the greens were punished. The evil
rapidly spread from night to day, and from the metropolis to other
cities. It would be futile in this case to quarrel with the details given
in the “Anecdotes.” The great riot into which the greens were stung
by this reign of terror is an historical fact; and nothing but the
vindictive memory of Theodora can explain how Justinian, the great
legislator, permitted so appalling a disorder.
Theodora meantime enjoyed the conversation of her monks and
hermits, and even Justinian seems to have been unconscious that he
was slipping the leash of beasts whom he might be powerless to
control. At length, on 14th January 532, the greens stirred. The
Emperor appeared in his kathisma at the Hippodrome, and an appeal
was made to him for justice. His officer replied disdainfully, and a
9
long and curious conversation took place. The Emperor still refused
to grant the impartial administration of justice or to punish the
murderers, and the greens left the Hippodrome. They gathered in
strength in the streets, and, although Justinian prudently sent to
learn and partly to remove their grievances, they remained in arms.
Belisarius was now sent against them with a troop of Goths, and the
rioting and burning began. Unfortunately for the Court an accident
then happened which had the singular effect of uniting the two
factions against the troops. Seven criminals were to be executed,
and Procopius cannot conceal the fact—in spite of his insistence that
the blues were never punished—that some of the seven were blues
and some greens. After five of the seven had been despatched, the
rope broke, and the crowd demanded the acquittal of the remaining
two. The authorities refused, and, as one criminal was a blue and
the other a green, the factions turned in common anger upon the
prefect and the troops.
The terrible riot that followed during four days must be read in
history. The first part of the palace, the great church of St Sophia,
and many other churches, mansions and public buildings were
destroyed. Priests who rushed into the fray holding aloft the
disarming emblems of their faith were cut down. On the fourth day,
a Sunday, Justinian entered the Hippodrome with a Bible in his hand,
and took a solemn oath to spare the offenders if they would disarm.
“Ass, thou art perjuring thyself,” was the infuriated answer; and he
retired to contemplate with Theodora the impending ruin of their
reign. On the following day the crowd forced Hypatius, nephew of
the Emperor Anastasius, to accept such purple robes as they could
obtain, marched with him in triumph to the Hippodrome, and exulted
in the downfall of Justinian and Theodora, who were believed to
have fled to Asia.
The “great” Justinian makes a lamentable appearance
throughout the whole riot, which he had guiltily occasioned, but
Theodora and the abler ministers were not minded to yield. As they
gathered in the hall of the palace, to which the cries in the
Hippodrome must almost have penetrated, the chief eunuch Narses
came to report that by a judicious distribution of money he had
distracted the factions and weakened the cause of Hypatius. It is
probably this news that turned the scale in the wavering counsels of
Justinian and his ministers, but it was Theodora who pressed it
home. The speech which Procopius assigns to her is worth
reproducing, though we cannot regard it as more than a rhetorical
paraphrase of the words she used:

“In my opinion this is no time to admit the maxim that a


woman must not act as a man among men; nor, if she fires
the courage of the halting, are we to consider whether she
does right or no. When matters come to a crisis, we must
agree as to the best course to take. My opinion is that,
although we may save ourselves by flight, it is not to our
interest. Every man that sees the light must die, but the man
who has once been raised to the height of empire cannot
suffer himself to go into exile and survive his dignity. God
forbid that I should ever be seen stripped of this purple, or
live a single day on which I am not to be saluted as Mistress.
If thou desirest to go, Emperor, nothing prevents thee. There
is the sea; there are the steps to the boats. But have a care
that when thou leavest here, thou dost not exchange this
sweet light for an ignoble death. For my part I like the old
saying: empire is a fine winding-sheet.”

Some such sentiments, we may believe, were urged by


Theodora, and affected the decision. The populace was penned in
the Hippodrome, and Justinian’s officers and troops stealthily
surrounded it. Rushing in at the various entrances, they fell with
such fury upon the people that the sun went down on the corpses of
between thirty and forty thousand citizens heaped in its arena or on
the terraced seats.
The health of Theodora suffered from the strain of this terrible
week, and she went to take the waters at the Pythian baths in
Bithynia: a crowd of nobles and four thousand soldiers and eunuchs
forming her retinue. Meantime Justinian set about the congenial task
of re-erecting the Chalke (or front part of the palace), the church of
St Sophia and the other ruined buildings, on a more splendid scale
than before. We shall see later by what means he and his Empress
obtained the prodigious sums of money they needed for their
enormous expenditure. We will also postpone for a moment the
early relations of Theodora to the general Belisarius and his romantic
spouse, and consider the next important episode in which her
character is seen.
In spite of the orthodoxy and religious zeal of Justinian, his wife
had such influence over him and apart from him that in the year 535
she secured the see of Constantinople for the Monophysite
Anthimus, to the unbounded delight of her sect and amidst the
furious maledictions of the orthodox throughout the Empire. Rome
was at that time regarded only as a sister Church of great authority
and antiquity, but its venerable Bishop Agapetus was summoned to
the Eastern metropolis and he succeeded in ousting Theodora’s
favourite. Agapetus, however, died soon afterwards at
Constantinople, and Theodora now conceived the bold design of
putting a Monophysite pope upon the throne at Rome itself. For the
remarkable events which follow I am not using the “Anecdotes” at
all. The story is told in substance by a contemporary ecclesiastical
writer, Liberatus the Deacon, of Carthage, and the chronicler Victor,
and is repeated, with large and legendary additions, by Anastasius,
the Roman librarian, of the ninth century.
In the suite of Agapetus at Constantinople was an ambitious and
courtly deacon named Vigilius, who contrived to let his
accommodating temper become known to the Empress. He was
taken to her apartments, and he promised, if the Roman see and a
large sum of money were bestowed on him, to reinstate Anthimus
and the other Monophysite bishops. In the meantime the Gothic
ruler of Italy had appointed a certain Silverius to the Roman see.
Theodora tested him with a request that he would restore Anthimus,
but he refused; murmuring, it is said, as he wrote the letter: “This
will cost me my life,” as it did. The Byzantine general Belisarius had
meantime taken and occupied Rome, and a few words must be said
to introduce him, and his wife Antonina, into the story of Theodora.
THE EMPRESS THEODORA AND HER ATTENDANTS
MOSAIC OF THE 6TH CENTURY IN S. VITALE, RAVENNA

I have previously mentioned an eleventh-century legend


concerning Belisarius and Justinian and their wives. It was said that
the two men had one day entered a house of ill-fame, found there
two captive and fascinating Amazons named Antonia [Theodora] and
Antonina, and married them. The myth seems to have crystallized
about a belief that Antonina had risen from the same depths as
Theodora, as the “Anecdotes” say, and the fact that Antonina was a
woman of abandoned character and a leading lady in the service of
the Empress seems to confirm this. In any case, she is openly
assailed by Procopius (her husband’s secretary) in his historical
works as “capable of anything,” and is described in the Lexicon of
Suidas as “an infamous adulteress.” She had married Belisarius, and
accompanied him in 533 on his brilliant campaign for the recovery of
Africa from the Vandals. With them went a handsome and foppish
Thracian youth named Theodosius. He was fresh from the baptismal
font, in which the patriarch had washed away his Monophysite
heresy, and it was believed that the presence of so sacred a youth
would bring luck to the fleet. Before they reached Carthage Antonina
enjoyed the secret love of the youth, but a servant betrayed them,
and Theodosius fled to Ephesus, where we must leave him for a
time. It is said that Antonina had the servant’s tongue cut out.
Belisarius passed from the subjugation of North Africa to a
victorious war in Italy, and he and Antonina were staying at a palace
on the Pincian Hill at Rome when the deacon Vigilius—now, no
doubt, a priest—came with the commands of Theodora. “Trump up a
charge against Silverius, and send him to Constantinople,” the order
ran, according to the Roman librarian, and as the more authoritative
Liberatus affirms that the charge was false, and was supported by
mendacious witnesses and forged letters, there is no possibility of
freeing Theodora from this grave imputation. The Pope was
summoned to the palace, where Antonina lay on a couch with
Belisarius at her feet. Antonina at once charged him with
treasonable correspondence with the Goths. We may or may not
believe the picturesque version of Anastasius: that the servants at
once stripped the Pope of his robes, dressed him as a monk, and
interred him in a distant monastery. It is certain, at least, that
Silverius was, at Theodora’s command, deposed on a false charge
and thrust out of sight. Vigilius became Pope, and the fate of
Silverius is unknown to history.
I cannot entirely omit a later sequel to this sacrilegious and
unscrupulous deed, though it rests only on the feebler authority of
Anastasius. For a few years Theodora demanded in vain that Vigilius
should fulfil his promise. He had, he said, come to see the
heinousness of such a promise, and could not discharge it. In 544,
therefore, Theodora sent an officer to Rome with a command which
Anastasius gives in these words: “If you find him in the church of St
Peter spare him, but if in the Lateran or the palace, or in any other
church, put him on ship at once, and bring him to us. If you fail, I
will, by Him that liveth for ever, have your skin torn from your body.”
It is known, at least, that Vigilius was shipped away from Rome at
the end of 544; but that he was at once taken to Constantinople,
and that Theodora had him dragged through the streets like a bear,
is untrue. He reached Constantinople after her death. We cannot
therefore follow the deposition of Vigilius as confidently as we follow
the sordid story of his elevation, but we can have little doubt that
Theodora punished him.
Another authentic episode of the time reveals the same
unscrupulous disdain of principles in the patroness of the
Monophysite sect. The story is told by Procopius, not in the
“Anecdotes,” but in his open and authoritative work “On the Persian
War,” in spite of his usual extreme care to suppress offensive details.
The Prefect of Constantinople, John of Cappadocia, had incurred the
bitter hostility of the Empress. The very unattractive portrait which
Procopius supplies, and Gibbon reproduces, of John prevents us
from thinking that in this case an innocent man was persecuted.
While he freely promoted all the schemes of Justinian and his
notorious steward to wring money out of the citizens—“by fair
means and foul,” as Zonaras says—he levied his private tithe on all
their gains, and was popularly believed to indulge in secret the most
sensual tastes and the even worse abominations of some pagan cult.
He seems to have been the one man to regard Theodora with open
disdain, and she retorted with venomous hate. Although guards
surrounded his bedroom, he started every hour from his feverish
slumbers to look for the expected assassin.
His value to Justinian enabled him to keep his position until the
year 540, when Belisarius and Antonina returned from Italy to
10
Constantinople. Antonina remained in the city while her husband
went against the Persians. She feverishly summoned her Thracian
lover from the monastery in which he hypocritically lingered at
Ephesus, but the wrath of Belisarius held him aloof. Whether or no
Antonina then deliberately sought the intervention of the Empress,
we cannot say, but she proceeded to merit it. She learned of
Theodora’s hatred of John, and conceived a plot for his destruction.
John had an ingenuous and amiable daughter who seems to
have been not unacquainted with the political situation. Twice had
the brilliant Belisarius been withdrawn to the city in a fit of jealousy,
and there were rumours that the strong man was wearying of
serving an Emperor who could do nothing but employ others and
reap their glory. Antonina won her way to the heart and confidence
of the girl, and betrayed to her that her husband was secretly
disaffected. The artless Euphemia hastened to tell her father that
there was a prospect of overthrowing Theodora, whom they both
hated. Even John was deceived by the astute adventuress. It was
arranged that Antonina should go to her suburban palace and meet
John there during the night. We do not know that Theodora had a
share in framing this diabolical plot, but it was now communicated to
her by Antonina, and she at once pressed it and used her resources
for carrying it out with safety. In the dead of the following night
John entered the palace of the unscrupulous adventuress and
listened to her whispers of treachery. Procopius says that Theodora
had initiated the Emperor to the plot, and he had consented, but at
the last moment sent a messenger to John not to see Antonina. This
seems to be a piece of polite fiction in the interest of the Emperor; it
is incredible that an astute and experienced minister would risk his
neck after such a message. John went, and, in the apparently lonely
palace, spoke his secret sympathy with the supposed design of
Belisarius. No sooner had he uttered the words than a troop of
imperial guards entered the room to arrest or assassinate him, but
John also had brought soldiers and they enabled him to escape.
Had John gone straight to the palace of Justinian, he might still
have saved his position. Instead, he fled nervously to the sanctuary,
and Theodora hardened the mind of her husband. The wealthy and
powerful noble was stripped of his estates and forced to enter the
ranks of the clergy—one of the quaintest penalties of the time—in
the suburb of Cyzicus. There the people whom he had oppressed
might behold their once powerful enemy, the secret pagan and
Sybarite, shaven and humiliated. It appears that Theodora was not
yet satisfied, though she is not directly implicated by Procopius in
the last act of the tragedy. The Bishop of Cyzicus was murdered, and
as John was one of his many bitter enemies, he was arrested,
scourged, and driven into exile and poverty. The fate of the unhappy
Euphemia is unknown; she was probably compelled to enter a
nunnery and weep there over the memory of the imperial tigress
and her friend.
This story of perfidy, corruption and vindictiveness, which
Procopius tells openly in his historical work, disposes us to believe
the sequel, as it is narrated in the “Anecdotes,” even if we must
regard certain details of the narrative with reserve. There was with
Belisarius in Persia a son of Antonina by a former husband (or lover)
of the name of Photius. Bitterly ashamed of his mother’s conduct, he
accepted from Belisarius the charge of watching her lover
Theodosius. At Ephesus he learned that Theodosius was in
Constantinople, and soon caused him to fly back to Ephesus and
cling to the altars which had sheltered so much vice and crime since
the law of sanctuary had been established. The prelate, however,
delivered Theodosius to the youth, and he was imprisoned in Cilicia.
Theodora was now eager to reward her friend and she had
Photius arrested and scourged. He refused to reveal the prison in
which he had placed Theodosius, but an officer was bribed to betray
the secret, and the Thracian was brought to Theodora’s apartments.
Theodora then sent for Antonina and said: “Dear patrician, yesterday
there fell into my hands a gem finer than any that mortal eye has
ever seen; if you would like to see it, I will show it to you.” Procopius
concludes this astounding story by saying that Photius was kept for
four years in the Empress’s underground dungeons. Twice he
escaped to the church of St Sophia, and twice he was dragged back;
at length he got away from Constantinople and hid from the
vindictiveness of Theodora in the robes of a monk. There are writers
who flatly refuse to believe this statement, though the authentic
actions of Theodora which we have described lend it some
plausibility. Once more, however, the recently published works of the
contemporary Bishop of Ephesus supply some confirmation. We read
in them that Photius, son of Antonina, “became a monk for some
cause or other”; but the pathos of Gibbon’s picture of his fate is
somewhat lessened when we read that he still enlivened the
monastic life with his genial soldierly vices and led the troops to the
plunder of the southern provinces.
I have mentioned the underground prisons of Theodora. Since it
is from the “Anecdotes” alone that we learn of these dungeons, we
should regard the statements with some reserve, and in this case
there is additional reason for reserve. As Gibbon says: “Darkness is
propitious to cruelty, but it is likewise favourable to calumny and
fiction.” Procopius seems to know too much of what passed in these
carefully guarded places. Theodora doubtless had spies everywhere,
and it would be easy enough for her to have her enemies conveyed
into the palace during the night, or to some prison in remote
provinces. Somewhere about this time (541), we learn from John of
Ephesus, her episcopal friend Anthimus incurred the anger of the
Emperor and disappeared. John assures us that Anthimus was
hidden in the Empress’s apartments for seven years. The two
chamberlains who waited on him alone knew the secret, besides
Theodora, until the day of her death. A woman with such resources
could easily maintain private dungeons if she willed, and we can
hardly say that it would be inconsistent with her character. But when
Procopius minutely describes the fetid condition of these prisons,
and tells how fiercely the prisoners were scourged, or how cords
were tightened round their heads until the eyes started from their
sockets, we are disposed to think that he has hastily admitted
popular rumours which the judicious historian must set aside as
unauthoritative.
On the other hand, a set of grave charges which Procopius
combines with these statements are not without very serious
confirmation. His most persistent charge against Justinian and
Theodora is that they extorted money by cruel and flagrantly
dishonest means. The superb buildings—the new palace, the new St
Sophia, etc.—with which Justinian adorned the city absorbed
stupendous sums of money; and the personal luxury and religious
munificence of Theodora were such that a vast fortune would be
needed to sustain them. It is equally certain that the money was
largely raised by corrupt means. I have quoted the monastic writer
Zonaras saying that Justinian raised money “by fair means and foul”
and by “dishonest practices”; and the weighty testimony of Evagrius
that the Emperor was of such “insatiable avarice” that he would
share the “vile gain” of loose women impeaching wealthy men on
false charges. The most that we can say for Justinian is that the
money was not spent in personal luxury, and that it was extorted by
subordinate officers. Agathias, another good authority, tells us how
the steward Anatolius used to forge or suppress wills, and practise
other dishonest arts, so that he might affix to houses and estates
the strip of purple which betokened that they had become the
property of the Emperor.
It is indisputable that the metropolis and the provinces suffered
a most unjust and corrupt spoliation in order to sustain the
splendour of the reign of Justinian and Theodora. Now Zonaras
declares that the Empress was “worse than Justinian in extorting
money, both by unlawful and lawful means,” and that she was
“especially ingenious in finding ways” to enrich herself. Wealthy men
had charges of secret heresy or unnatural vice brought against
them, and their fortunes passed into the coffers of Theodora. This
must mean that her servants, as the informers, claimed for her the
legal share of the confiscated property which went to an informer.
Here again, therefore, the charges in the “Anecdotes” are
substantially confirmed. Not content with securing testaments in her
favour, she had them forged or altered. She suborned witnesses to
support charges of vice or heresy. The only difference from Zonaras
is in the added allegation of physical cruelty, and on this point
Procopius is at times explicit. A member of the blue party, Bassus, a
refined and delicate youth, issued some squib upon the Empress,
possibly referring to her early career. He was dragged from the
church in which he had taken refuge, charged with and convicted of
vice, and subjected, before an indignant crowd, to the barbaric
mutilation with which such vice was then punished. His property
went to Theodora—in part, I assume, for laying information. Usually
it was the greens who suffered. So angry were the people that they
accused Theodora of a secret (but “impotent”) love of the sinister
Syrian financier, Peter Barsymes, who had succeeded John of
Cappadocia in the duty of governing and exploiting Constantinople.
The restraint with which Procopius represents her love as “impotent”
lends credit to his other charges. An accusation of an actual liaison
would have been more credible than some of the stories he
reproduces.
A few episodes remain in the career of Theodora from which we
may confirm our impression of her remarkable personality.
Unfortunately, they rest entirely on the authority of the “Anecdotes,”
and cannot be pressed; we know only from another, and a sound,
authority that Belisarius was maliciously attacked and disgraced after
his many brilliant campaigns on behalf of the Empire.
To the evils of oppression, spoliation, corruption of justice, and
persecution which afflicted the Eastern Empire under Justinian and
Theodora there was added in the year 542 the deadly scourge of the
plague, and for several years in succession it scattered the seeds of
death over the broad provinces. Justinian at length contracted it,
and became dangerously ill. As he had no son, the question of the
succession to the throne was very naturally discussed, and the
generals Belisarius and Buza in the Persian camp incautiously
expressed themselves on the rumour that Justinian was dying, or
were represented to the Empress by her spies as having done so.
She at once ordered them to Constantinople. Buza is said to have
been lodged in her underground prisons, and Belisarius was stripped
of his rank, his guard and his immense wealth. A eunuch was sent
by Theodora to secure the large sums he had deposited in the east,
and the chosen soldiers who formed his personal guard, and were
maintained at his expense, were distributed among the army. The
greatest soldier that the Eastern Empire ever possessed, the most
brilliant contributor to the success of Justinian’s reign, a man who
had preserved his loyalty in a decade of supreme military power, he
was received at the palace with cold haughtiness, and retired in
deep distress to his mansion. When at length he observed the
approach of a servant of the Empress, he prepared for death.
Instead of death, however, Theodora’s officer brought this
extraordinary message: “You know what you have done to me,
Belisarius, but I forgive your crimes on account of what your wife
has done for me. Hope for the future through her, but know that we
shall hear how you bear yourself to Antonina.” And the episode
closes with the great soldier kissing the feet of his perfidious wife,
vowing that he will be her slave, and accepting the office of master
of the stables in the imperial service which he had so gloriously
illumined. Theodora had secured an enormous sum of money and
intimidated an enemy.
Up to the last year of Theodora’s life (548) the implacable writer
of the “Anecdotes” pursues his record of her misdeeds. Ever
attentive to the men who might some day dislodge her and her
relatives from the palace, Theodora watched with especial jealousy
the grave and distinguished nephew of the Emperor, Germanus, and
his three children. His eldest daughter Justina was in her nineteenth
year, yet none had dared, out of fear of Theodora, to offer marriage
to her. Theodora then decided to unite the fortunes of the two
houses, and secure the succession, by commanding Justina to wed
her grandson Anastasius—obviously the son of an illegitimate
daughter of the Empress, since it was little over twenty years since
her marriage to Justinian. Justina refused, and was vindictively
married by the Empress to a common officer. She then commanded
the daughter of Belisarius, Joannina, to wed Anastasius. Procopius,
forgetting that he has stripped Belisarius of almost all his wealth (an
exaggeration), says that Theodora wanted in this way to secure the
general’s fortune, but we may assume that Theodora was mainly
endeavouring to secure the succession to the throne for her
grandson. Her own health was delicate, and Justinian was well over
sixty. Belisarius shrank from the union, and even Antonina seems to
have refused to further it. All knew that a struggle impended
between the families of Justinian and Theodora, and it must have
been the general feeling that the former would win. Theodora is said
to have angrily united Joannina to her grandson in the loose popular
form of marriage; indeed later rumour said that she had the young
woman violated first.
Another matrimonial interference of the Empress in her later
years exhibits the better features of her character. An ambitious
general, Artabanes, sought and obtained the hand of Justinian’s
niece, whom he had delivered from peril in Africa. Soon afterwards,
however, a woman appeared who claimed that she was the
legitimate wife of Artabanes. She appealed to the Empress, and
Theodora forced Artabanes to take back his humbler wife. Procopius
tells this story in one of the historical works in which he was careful
not to offend the ruling powers, and he courteously adds that “it was
the nature of Theodora to befriend afflicted women.” It is the only
instance of her doing so that has reached us, and, ungracious as it
may seem to cast a doubt upon the pure humanity of that one
recorded good deed, one is compelled to suggest that it was not to
her interest to see a niece of Justinian married to a successful
commander.
On the 29th of June 548, after a reign of twenty-one years,
Theodora died of cancer. Her body was embalmed and exposed for
public veneration in the golden-roofed Triclinon of the palace. There,
still dressed in the imperial purple, still bearing the magnificent
diadem for a few days, she lay on a golden bed for friends and
enemies to gaze upon the last state of one of the most remarkable
personalities of the time.
The character of Theodora must be interpreted in so purely
oriental a sense that it is difficult for the modern European to
understand it. Whether Greek or Syrian in origin, she was an
incarnation of the spirit of the great metropolis in whose life Syria
and Greece were so singularly blended. It is useless any longer to
cast doubt upon her earlier career. She was reared in that old
theatrical world in which moral restraint was wholly unknown; and
her beauty, vivacity and nervous strength make it probable enough
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like