jQuery Mobile Web Development Essentials 2nd Edition Build mobile optimized websites using the simple practical and powerful jQuery based framework Raymond Camden pdf download
jQuery Mobile Web Development Essentials 2nd Edition Build mobile optimized websites using the simple practical and powerful jQuery based framework Raymond Camden pdf download
https://ebookgate.com/product/jquery-mobile-1st-edition-jon-reid/
ebookgate.com
https://ebookgate.com/product/working-with-jqtouch-to-build-websites-
on-top-of-jquery-1-aufl-edition-david/
ebookgate.com
https://ebookgate.com/product/build-mobile-websites-and-apps-for-
smart-devices-1st-edition-earle-castledine/
ebookgate.com
jQuery 1 4 animation techniques beginner s guide quickly
master all of jquery s animation methods and build a
toolkit of ready to use animations using jQuery 1 4 1st
Edition Dan Wellman
https://ebookgate.com/product/jquery-1-4-animation-techniques-
beginner-s-guide-quickly-master-all-of-jquery-s-animation-methods-and-
build-a-toolkit-of-ready-to-use-animations-using-jquery-1-4-1st-
edition-dan-wellman/
ebookgate.com
https://ebookgate.com/product/jquery-pocket-primer-oswald-campesato/
ebookgate.com
https://ebookgate.com/product/head-first-jquery-ryan-benedetti/
ebookgate.com
Second Edition
Raymond Camden
Andy Matthews
BIRMINGHAM - MUMBAI
www.it-ebooks.info
jQuery Mobile Web Development Essentials
Second Edition
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy
of the information presented. However, the information contained in this book is
sold without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78216-789-1
www.packtpub.com
www.it-ebooks.info
Credits
Production Coordinator
Acquisition Editor
Melwyn D'sa
Usha Iyer
Cover Work
Lead Technical Editor
Melwyn D'sa
Sweny M. Sukumaran
Technical Editors
Dennis John
Gaurav Thingalaya
www.it-ebooks.info
About the Authors
Raymond Camden is a Senior Developer Evangelist for Adobe. His work focuses
on web standards, mobile development, and ColdFusion. He's a published author,
and presents at conferences and user groups on a variety of topics. Raymond can
be reached at his blog at www.raymondcamden.com, followed on Twitter
(@cfjedimaster), or contacted via e-mail at [email protected].
As always, I dedicate this book to the one person who made this all
possible, my wife Jeanne. Thank you for believing in me and being
strong when I am not. I will love you always.
I'd like to thank everyone on the jQuery and jQuery Mobile teams
for making tools that have changed my life. Without your hard work
and dedication, the Web would be less awesome. Thank you Andy
for coming on board and helping to make this book better.
Andy Matthews has been working as a web and application developer for over
16 years, with experience in a wide range of industries, and a skillset that includes
UI/UX, graphic design, and programming. He is the co-author of the book jQuery
Mobile Web Development Essentials, Packt Publishing, and writes for online publications
such as NetTuts and .NET Magazine. He is a frequent speaker at conferences
around the country, and he has developed software for the open source community
including several of the most popular jQuery Mobile projects on the Web. He blogs
at andyMatthews.net, tweets at @commadelimited, and lives in Nashville, TN, with
his wife and four children.
www.it-ebooks.info
About the Reviewers
You can reach Matt on Twitter via @coldfumonkeh or through his blog.
www.it-ebooks.info
Eliecer Daza Parra has been a web developer since 2005. He has got ample
experience in Java, Python, PHP, jQuery, and jQuery Mobile. Elicer has an experience
of more than 8 years as a Java developer. He has been a software developer for
Information Management and Customer Relationship Management (CMR) for health
promoting enterprises (EPS), public transportation, and education companies in the
private and public sectors. He has been working as a Python developer since more
than 2 years, working with responsive websites.
Among the main areas of his interest are the development of Linux, Python, Android,
and Google Services. He has a huge interest in nurturing blog spaces about Linux
administration and programming.
Olivier Pons is a developer who's been building websites since 1997. He's a
teacher at Ingésup (École supérieure d'ingénierie informatique), the University of
Sciences (IUT) of Aix-en-Provence, France where he teaches Linux, Apache HTTP
server, PHP, jQuery/jQuery Mobile, advanced website optimization, and advanced
VIM techniques. He has already written some technical reviews, including the
Packlib book Ext JS 4 First Look. In 2011, he left a full-time job as a Delphi and PHP
developer to concentrate on his own company, HQF Development (http://hqf.
fr). He currently runs a number of websites, including http://www.livrepizzas.
fr, http://www.papdevis.fr, and http://olivierpons.fr—his own web
development blog. He currently works as a consultant, project manager, and
senior developer.
www.it-ebooks.info
www.PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and
as a print book customer, you are entitled to a discount on the eBook copy. Get in touch
with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital
book library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
• Fully searchable across every book published by Packt
• Copy and paste, print and bookmark content
• On demand and accessible via web browser
www.it-ebooks.info
www.it-ebooks.info
Table of Contents
Preface 1
Chapter 1: Preparing Your First jQuery Mobile Project 11
Important preliminary points 11
Building an HTML page 11
Getting jQuery Mobile 13
Customized downloads 14
Implementing jQuery Mobile 14
Working with data attributes 16
Summary 18
Chapter 2: Working with jQuery Mobile Pages 19
Important preliminary points 19
Adding multiple pages to one file 20
jQuery Mobile, links, and you 22
Working with multiple files 23
jQuery Mobile and URLs 25
Additional customization 26
Page titles 26
Prefetching content 26
Changing page transitions 27
Summary 28
Chapter 3: Enhancing Pages with Headers, Footers, and Toolbars 29
Important preliminary points 29
Adding headers 29
Icon sneak peak 31
Working with back buttons 31
Working with footers 33
www.it-ebooks.info
Table of Contents
[ ii ]
www.it-ebooks.info
Table of Contents
[ iii ]
www.it-ebooks.info
Table of Contents
[ iv ]
www.it-ebooks.info
Table of Contents
[v]
www.it-ebooks.info
www.it-ebooks.info
Preface
Welcome to jQuery Mobile Web Development Essentials, Second Edition. Both myself and
Andy Matthews have tried our best to create a book that introduces and prepares
you for building mobile-friendly websites with jQuery Mobile.
But what do we mean when we refer to a "UI framework"? What does it mean for
developers and designers? jQuery Mobile provides a way to turn regular HTML
(and CSS) into mobile-friendly sites. As you will see in the book, you can take a
regular HTML page, add in the required bits for jQuery Mobile (essentially five lines
of HTML), and find your page transformed into a mobile-friendly version instantly.
www.it-ebooks.info
Preface
It will make sense to anyone who accidentally clicked a Reset button instead of
Submit. jQuery Mobile will enhance your content to help solve these issues. Regular
buttons become large, fat, and easy to hit. Links can be turned into list-based
navigation systems. Content can be split into virtual pages with smooth transitions.
You will be surprised just how much jQuery Mobile will do for you without writing
much code at all.
jQuery Mobile has some very big sponsors. They include Nokia, Blackberry, Adobe,
and other large companies. These companies have invested money, hardware, and
developer resources to help ensure the success of the project.
[2]
www.it-ebooks.info
Preface
Again, if you want to develop true mobile apps with jQuery Mobile, it's definitely
an option.
Help!
While we'd like to think that this book will cover every single possible topic you
would need for all your jQuery Mobile needs, there will most likely be things we
can't cover. If you need help, there are a couple of places you can try.
[3]
www.it-ebooks.info
Preface
Examples
Do you want to see jQuery Mobile in action? There's a site for that. JQM Gallery
(http://www.jqmgallery.com/) is a collection of user-submitted sites built using
jQuery Mobile. Not surprisingly, it too uses jQuery Mobile that makes it yet another
way to sample jQuery Mobile.
Chapter 2, Working with jQuery Mobile Pages, continues the work in the previous
chapter and introduces the concept of jQuery Mobile pages.
Chapter 3, Enhancing Pages with Headers, Footers, and Toolbars, explains how to enhance
your pages with nicely formatted headers and footers.
Chapter 4, Working with Lists, describes how to create jQuery Mobile listviews.
These are mobile-optimized lists that are especially great for navigation.
[4]
www.it-ebooks.info
Preface
Chapter 5, Getting Practical – Building a Simple Hotel Mobile Site, walks you through
creating your first "real" (albeit simple) jQuery Mobile application.
Chapter 6, Working with Forms and jQuery Mobile, walks you through the process of
using jQuery Mobile-optimized forms. Layout and special form features are covered
in detail.
Chapter 7, Creating Modal Dialogs and Widgets, walks you through special jQuery
Mobile user interface items for creating grid-based layouts, dialogs, and collapsible
content areas.
Chapter 8, Moving Further with the Notekeeper Mobile Application, walks you through the
process of creating another website, an HTML5-enhanced note taking application.
Chapter 9, jQuery Mobile Configuration, Utilities, and JavaScript Methods, describes the
various JavaScript-based utilities your code may require.
Chapter 10, Working with Events, details the events thrown by various jQuery
Mobile-related features, such as pages loading and unloading.
Chapter 11, Enhancing jQuery Mobile, demonstrates how to change the default
appearance of your jQuery Mobile sites by selecting and creating unique themes.
Chapter 12, Creating Native Applications, takes what you've learned previously and
shows how to use the open source PhoneGap project to create real native applications.
Chapter 13, Becoming an Expert – Building an RSS Reader Application, expands upon
the previous chapter by creating an application that lets you add and read RSS feeds
on mobile devices.
[5]
www.it-ebooks.info
Preface
There are good IDEs out there that can help you be more productive. Adobe
Dreamweaver CC, for example, includes native support for jQuery Mobile
with code assist and device previews.
At the end of the day, you can develop with jQuery Mobile for free. It's zero cost
for you to download, develop, and publish jQuery Mobile sites.
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
Code words in text are shown as follows: "Notice the new data-title tag added
to the div tag."
[6]
www.it-ebooks.info
Preface
New terms and important words are shown in bold. Words that you see on
the screen, in menus or dialog boxes, for example, appear in the text like this:
"Imagine our Megacorp page. It's got three pages, but the Products page is
a separate HTML file."
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this book—what you liked or may have disliked. Reader feedback is important for
us to develop titles that you can really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things
to help you to get the most from your purchase.
[7]
www.it-ebooks.info
Preface
If you are not familiar with Git, then simply click on the Downloads tab and then
either Download as zip or Download as tar.gz to quickly get an archived collection
of all the files.
You should extract these files onto a local web server. If you do not have one
installed, we recommend installing Apache (http://httpd.apache.org/). Apache
works on all platforms, is free, and is typically easy to install. Once extracted, you
can edit these files, view them in your browser, or copy them as a starting point for
your own projects.
You can download the example code files for all Packt books you have purchased
from your account at http://www.packtpub.com. If you purchased this book
elsewhere, you can visit http://www.packtpub.com/support and register to
have the files e-mailed directly to you.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in the text or
the code—we would be grateful if you would report this to us. By doing so, you can
save other readers from frustration and help us improve subsequent versions of this
book. If you find any errata, please report them by visiting http://www.packtpub.
com/support, selecting your book, clicking on the errata submission form link, and
entering the details of your errata. Once your errata are verified, your submission
will be accepted and the errata will be uploaded to our website, or added to any list
of existing errata, under the Errata section of that title.
[8]
www.it-ebooks.info
Preface
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media.
At Packt, we take the protection of our copyright and licenses very seriously. If you
come across any illegal copies of our works, in any form, on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.
We appreciate your help in protecting our authors, and our ability to bring
you valuable content.
Questions
You can contact us at [email protected] if you are having a problem
with any aspect of the book, and we will do our best to address it.
[9]
www.it-ebooks.info
www.it-ebooks.info
Preparing Your First jQuery
Mobile Project
You know what jQuery Mobile is, the history of it as well as its features and goals.
Now we're actually going to build our first jQuery Mobile website (well, web page)
and see how easy it is to use.
www.it-ebooks.info
Preparing Your First jQuery Mobile Project
As we said, there is nothing too complex, right? Let's take a quick look at this
in the browser:
Not so bad, right? But let's take a look at the same page in a mobile simulator:
[ 12 ]
www.it-ebooks.info
Chapter 1
Wow, that's pretty tiny. You've probably seen web pages like this before on your
mobile device. You can, of course, typically use pinch and zoom or double-click
actions to increase the size of the text. But it would be preferable to have the page
render immediately in a mobile-friendly view. This is where jQuery Mobile comes in.
[ 13 ]
www.it-ebooks.info
Preparing Your First jQuery Mobile Project
At the time this book was written, jQuery Mobile was preparing for
the release of Version 1.4. Obviously, by the time you read this book
a later version may have been released. The file names you see listed
in the previous screenshot are version specific, so keep in mind they
may look a bit different for you.
Notice the ZIP file contains a CSS and JavaScript file for jQuery Mobile, as well as a
minified version of both. You will typically want to use the minified version in your
production apps and the regular version while developing. The images folder has
five images used by the CSS when generating mobile optimized pages. You will also
see demos for the framework as well as theme and structure files (You won't need
to use those for this book). So, to be clear, the entire framework and all the features
we will be talking about over the rest of the book will consist of a framework of 6
files. Of course, you also need to include the jQuery library. You can download that
separately at www.jquery.com. At the time this book was written, the recommended
version was 1.9.1.
Customized downloads
As a final option for downloading jQuery Mobile, you can also use a customized
Download Builder tool at http://jquerymobile.com/download-builder. Currently
in Alpha (that is, not certified to be bug-free!), the web-based tool lets you download
a jQuery Mobile build minus features your website doesn't need. This creates smaller
files which reduces the total amount of time your application needs to display to the
end user.
1. First, add the HTML5 DOCTYPE to the page: <!DOCTYPE html>. This is used
to help inform the browser about the type of content it will be dealing with.
2. Add a viewport metatag: <metaname="viewport"content="width=dev
ice-width,initial-scale="1">. This helps set better defaults for pages
when viewed on a mobile device.
3. Finally, the CSS, JavaScript library, and jQuery itself need to be included into
the file.
[ 14 ]
www.it-ebooks.info
Chapter 1
Let's look at a modified version of our previous HTML file that adds all of the above:
code 1-2: test2.html
<!DOCTYPE html>
<html>
<head>
<title>First Mobile Example</title>
<meta name="viewport" content="width=device-width, initial-
scale=1">
<link rel="stylesheet"href="jquery.mobile-1.3.2.min.css" />
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript"src="jquery.mobile-
1.3.2.min.js"></script>
</head>
<body>
<h1>Welcome</h1>
<p>
Welcome to our first mobile web site. It's going to be the best
site you've ever seen. Once we get some content. And a
business
plan. But the hard part is done!
</p>
<p>
<i>Copyright Megacorp© 2013</i>
</p>
</body>
</html>
For the most part, this version is the exact same as Code 1-1, except for the addition
of the DOCTYPE, the CSS link, and our two JavaScript libraries. Notice we point to the
hosted version of the jQuery library. It's perfectly fine to mix local JavaScript files
and remote ones. If you wanted to ensure you could work offline, you can simply
download the jQuery library as well.
[ 15 ]
www.it-ebooks.info
Preparing Your First jQuery Mobile Project
So while nothing changed in the code between the body tags, there is going to be a
radically different view now in the browser. The following screenshot shows how
the iOS mobile browser renders the page now:
Right away, you see a couple of differences. The biggest difference is the relative
size of the text. Notice how much bigger it is and easier to read. As we said, the user
could have zoomed in on the previous version, but many mobile users aren't aware
of this technique. This page loads up immediately in a manner that is much more
usable on a mobile device.
HTML5 introduced the concept of data attributes as a way to add ad-hoc values to
the DOM (Document Object Model). As an example, this is a perfectly valid HTML:
<div id="mainDiv" data-ray="moo">Some content</div>
www.it-ebooks.info
Chapter 1
This is where jQuery Mobile comes in, making extensive use of data attributes,
both for markup (to create widgets) and behavior (to control what happens when
links are clicked). Let's look at one of the main uses of data attributes within jQuery
Mobile—defining pages, headers, content, and footers:
code 1-3: test3.html
<!DOCTYPE html>
<html>
<head>
<title>First Mobile Example</title>
<meta name="viewport" content="width=device-width, initial-
scale=1">
<link rel="stylesheet"href="jquery.mobile-1.3.2.min.css" />
<script type="text/javascript"src="http://code.jquery
.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript"src="jquery.
mobile-1.3.2.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header"><h1>Welcome</h1></div>
<div data-role="content">
<p>
Welcome to our first mobile web site. It's going to be the
best site you've ever seen. Once we get some content. And
a business plan. But the hard part is done!
</p>
</div>
<div data-role="footer">
<h4>Copyright Megacorp© 2013</h4>
</div>
</div>
</body>
</html>
Compare the previous code snippet to code 1-2, and you can see that the main
difference was the addition of the div blocks. One div block defines the page. Notice
it wraps all of the content inside the body tags. Inside the body tag, there are three
separate div blocks. One has a role of header, another a role of content, and the
final one is marked as footer.
[ 17 ]
www.it-ebooks.info
Preparing Your First jQuery Mobile Project
All the blocks use data-role, which should give you a clue that we're defining a role
for each of the blocks. As we stated previously, these data attributes mean nothing to
the browser itself. But let's look what at what jQuery Mobile does when it encounters
these tags:
Notice right away that both the header and footer now have a black background
applied to them. This makes them stand out even more from the rest of the content.
Speaking of the content, the page text now has a bit of space between it and the
sides. All of this was automatic once the div tags with the recognized data-roles
were applied. This is a theme you're going to see repeated again and again as we go
through this book. A vast majority of the work you'll be doing will involve the use of
data attributes.
Summary
In this chapter, we talked a bit about how web pages may not always render well in a
mobile browser. We talked about how the simple use of jQuery Mobile can go a long
way to improving the mobile experience for a website. Specifically, we discussed
how you can download jQuery Mobile and add it to an existing HTML page, what
data attributes mean in terms of HTML, and how jQuery Mobile makes use of data
attributes to enhance your pages. In the next chapter, we will build upon this usage
and start working with links and multiple pages of content.
[ 18 ]
www.it-ebooks.info
Working with jQuery
Mobile Pages
In the previous chapter you saw how easy it was to add jQuery Mobile to a simple
HTML page. While it would be nice if every website consisted of one and only one
page, real websites consist of multiple pages connected via links. jQuery Mobile
makes it easy to work with multiple pages, and provides many different ways to
create and link the pages.
Starting with this chapter, we will be presenting only the most relevant parts of each
code snippet. The first code snippet, typically, will include all the code, while later
code snippets will focus on the important sections. Be sure to reference the complete
code snippets available via the downloaded ZIP file.
www.it-ebooks.info
Working with jQuery Mobile Pages
[ 20 ]
www.it-ebooks.info
Chapter 2
Ok, so as always, we begin our template with a few required bits: the HTML5
DOCTYPE, the meta tag, one CSS include, and two JavaScript files. This was covered
in the previous chapter and we will not be mentioning it again. Note that this
template switches over to the CDN version of the CSS and JavaScript libraries:
<link rel="stylesheet" href="http://code.jquery.com/
mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/
jquery.mobile-1.3.2.min.js"></script>
These versions are hosted by the jQuery team. Most likely, your visitors will have
loaded these libraries already so they exist in their cache before arriving at your
mobile site. While this is the route we will take going further with our examples,
remember that you can always use the version you downloaded instead.
Notice now we have two <div> blocks. The first hasn't much changed from the
previous example. We've added a unique ID (homepage), as well as a second
paragraph. Notice the link in the second paragraph. It's using a standard internal
link (#aboutPage) to tell the browser that we want to simply scroll the browser
down to that part of the page. The target specified, aboutPage, is defined right
below in another div block.
[ 21 ]
www.it-ebooks.info
Working with jQuery Mobile Pages
In a traditional web page, this would display as two main blocks of text on a
page. Clicking any of the two links would simply scroll the browser up and down
accordingly. However, jQuery Mobile is going to do something significantly different
here. The following figure shows how the page is rendered in the mobile browser:
Notice something? Even though our HTML included two blocks of text (the two
<div> blocks), it only rendered one. jQuery Mobile will always display the first page
it finds, and only that page. Here comes the best part. If you click on the link, the
second page automatically loads. Using your device's back button or simply clicking
on the link will return you back to the first page. (Obviously this only works on
devices that have a back button, for example Android devices.) You will also notice
a smooth transition. This is something you can configure later on. But all of the
interactions here, the showing and hiding of pages, and the transitions, were all done
automatically by jQuery Mobile. Now is a good time to talk about links and what
jQuery Mobile does when you click on them.
[ 22 ]
www.it-ebooks.info
Chapter 2
If you link to an external site, then jQuery Mobile will leave the link as it is, and
the normal link behavior will occur. There may be times when you want to disable
jQuery Mobile from doing anything with your links at all. In that case, you can make
use of a data attribute that lets the framework know it shouldn't do anything at all.
An example:
<a href="foo.html" data-ajax="false">Normal, non-special link</a>
As we saw in Chapter 1, Preparing Your First jQuery Mobile Project, jQuery Mobile
makes heavy use of data attributes. It is also very good at letting you disable
behaviors you don't like. As we continue in the book you will see example after
example of something jQuery Mobile does to enhance your site for mobile devices.
In all of these cases though, the framework recognizes there may be times when you
want to disable that.
To work with multiple pages, and files, all we need to do is make a simple link
to other files in the same domain as our first file. We can even combine the first
technique (two pages in one file) with links to other files. In code 2-2, we've
modified the first example to add a link to a new page. (As mentioned previously,
we are only listing the relevant portion of the page!)
code 2-2:test2.html
<div data-role="page" id="homePage">
<div data-role="header"><h1>Welcome</h1></div>
<div data-role="content">
<p>
Welcome to our first mobile web site. It's going to be the
best site you've ever seen. Once we get some content. And
a business plan. But the hard part is done!
</p>
<p>
Find out about our wonderful
<a href="products.html">products</a>.
[ 23 ]
www.it-ebooks.info
Working with jQuery Mobile Pages
</p>
<p>
You can also <a href="#aboutPage">learn more</a> about
Megacorp.
</p>
</div>
<div data-role="footer">
<h4>Copyright Megacorp © 2013</h4>
</div>
</div>
<body>
<div data-role="page" id="productsPage">
<div data-role="header"><h1>Products</h1></div>
<div data-role="content">
<p>
Our products include:
</p>
<ul>
<li>Alpha Series</li>
<li>Beta Series</li>
<li>Gamma Series</li>
</ul>
</div>
</div>
</body>
</html>
[ 24 ]
www.it-ebooks.info
Chapter 2
Our products page is rather simple, but notice that we included the jQuery and
jQuery Mobile resources on top. Why? I mentioned earlier that jQuery Mobile is
going to use AJAX to load in your additional pages. If you open up test2.html in
any modern browser you can see for yourself using developer tools. Clicking on the
link for products will fire an XHR (XHR means XML HTTP Request, but generally
just means an AJAX call) request, as shown in the following screenshot from
Chrome's DevTools:
That's neat! But what happens when someone bookmarks the application? Let's now
take a look at how jQuery Mobile handles URLs and navigation.
In both subpages (the Products page and the About page) the URL was changed
by the framework itself. The framework uses history.pushState and history.
replaceState in browsers that support it. For older browsers, or browsers that don't
support JavaScript manipulation of the URL, hash-based navigation is used instead.
The products link, when viewed in an older Internet Explorer, looks like the following:
http://localhost/mobile/c2/test2.html#/mobile/c2/products.html
[ 25 ]
www.it-ebooks.info
Working with jQuery Mobile Pages
Additional customization
Working with multiple pages in jQuery Mobile is pretty simple. You could take
what's been discussed in the first two chapters and build a pretty simple, but mobile
compliant website right now. The following are a few more interesting tricks you
may want to consider.
Page titles
You may have noticed when you clicked on the Products page in the previous
example, the title of the browser correctly updated to Products. This is because
jQuery Mobile noticed, and parsed in, the title tag from the products.html file.
If you click the learn more link, you will notice the title also updates. How did
that work? When the About page was loaded, jQuery Mobile used the header
tag's content (About Megacorp) for a title. You can override this by providing
an additional argument to your div tag defining your page: data-title.
The following code snippet demonstrates this feature:
<div data-role="page" id="aboutPage" data-title="All About
Megacorp">
<div data-role="header"><h1>About Megacorp</h1></div>
Prefetching content
The benefit of including all your content within one HTML file is that all of your
pages are available immediately. But the negatives (too difficult to update, too
slow for an initial download) far outweigh that. Most jQuery Mobile applications
will include multiple files, and typically just use one or two pages per file. You
can, however, ensure speedier loading of some pages to help improve the user
experience. Imagine our Megacorp site. It's got three pages, but the Products page is
a separate HTML file. Since it's the only real content on the site, most likely all of our
users will end up clicking that link. We can tell jQuery Mobile to prefetch the content
[ 26 ]
www.it-ebooks.info
Chapter 2
immediately upon the main page loading. That way, when the user does click the
link, the page will load much quicker. Once again, this comes down to one simple
data attribute.
<p>
Find out about our wonderful <a href="products.html" data-
prefetch="true">products</a>.
</p>
In the previous link, all we've done is added data-prefetch="true" to the link.
When jQuery Mobile finds this in a link, it will automatically fetch the content right
away. Now, when the user clicks the Products link, they will see the content even
quicker. This modification was saved in test4.html.
Obviously, this technique should be used with care. Given a page with four main links,
you may want to consider only prefetching the two most popular pages, not all four.
Valid values for transition include: fade (the default), flip, flow, pop, slide,
slidedown, slidefade, turn, and none.
Many transitions also support a reverse action. Normally jQuery Mobile figures out
if you need this, but if you want to force a direction, use the data-direction attribute:
<p>
Find out about our wonderful <a href="products.html" data-
transition="pop" data-direction="reverse">products</a>.
</p>
[ 27 ]
www.it-ebooks.info
Working with jQuery Mobile Pages
Summary
This chapter further fleshed out the concept of jQuery Mobile pages, and how to
work with multiple pages. Specifically, we saw how one physical file can contain
many different pages. jQuery Mobile will handle hiding all but the first page. We
also saw how you can link to other pages, and how jQuery Mobile uses AJAX to
dynamically load the content into the browser. Next, we discussed how jQuery
Mobile handles updating the URL of the browser in order to enable bookmarking.
Finally, we discussed two utilities that will help to improve your page. The first way
was to provide a title for embedded pages. The second technique demonstrated how
to prefetch content to further improve the experience of the users visiting your site.
In the next chapter, we'll take a look at headers, footers, and navigation bars.
These will greatly enhance our pages and make them easier to navigate.
[ 28 ]
www.it-ebooks.info
Enhancing Pages with
Headers, Footers,
and Toolbars
Toolbars provide a simple way to add navigation elements to a mobile website.
They can be especially useful for consistent or site-wide navigation controls that
users can always refer to when navigating through your application.
Adding headers
You've already worked with headers in the previous chapter, so the code will be
familiar. In this chapter, we will study them deeper and demonstrate how to add
additional functionality, such as buttons, to your site headers.
www.it-ebooks.info
Enhancing Pages with Headers, Footers, and Toolbars
If you remember, a header can be defined by simply using a div with the
appropriate role:
<div data-role="header"><h1>My Header</h1></div>
When viewed in the mobile browser, you can see that the links were automatically
turned into buttons:
Notice how the simpler links were automatically turned into big buttons, making
them easier to use and more "control-like" for the header. You may be wondering,
what if you only want one button, and want it on the right-hand side? Removing the
first button and keeping the second in place will not work, as shown in the following
code snippet:
<div data-role="header">
<h1>My Header</h1>
<a href="contact.html">Contact</a>
</div>
The previous code snippet creates a button in the header but on the left-hand side.
In order to position the button to the right, simply add the class ui-btn-right.
code 3-2: header_test2.html
<div data-role="header">
<h1>My Header</h1>
<a href="contact.html" class="ui-btn-right">Contact</a>
</div>
[ 30 ]
www.it-ebooks.info
Other documents randomly have
different content
plunder was abandoned in their retreat. The
conquerors would have exposed themselves by a rash
pursuit, but Palafox exhorted them not to be
impatient, telling them, that the enemy would give
them frequent opportunities to display their courage.
While he thus restrained their impetuosity, he
continued to excite their zeal. This victory, he said,
was but the commencement of the triumphs which
they were to expect under the powerful assistance of
their divine patrons. The precious blood of their
brethren had been shed in the field of glory, ... on
their own soil. Those blessed martyrs required new
victims; let us, he added, prepare for the sacrifice!
Palafox goes The Zaragozans had obtained only a respite;
out to collect defeated as he was, Lefebvre had only removed
reinforcements. beyond the reach of their guns; his troops were far
superior to any which they could bring against him;
and it was not to be doubted that he would soon
return in greater force, to take vengeance for the
repulse and the disgrace which he had suffered. A
regular siege was to be expected; how were the
citizens to sustain it with their brick walls, without
heavy artillery, and without troops who could sally to
interrupt the besiegers in their works? In spite of all
these discouraging circumstances, confiding in God
and their own courage, they determined to defend the
streets to the last extremity. Palafox, immediately
after the repulse of the enemy, set out to muster
reinforcements, to provide such resources for the
siege as he could, and to place the rest of Aragon in a
state of defence, if the capital should fall. He was
accompanied by Colonel Butron, his friend and aide-
de-camp; Lieut.-Colonel Beillan, of the engineers;
Padre Basilio, and Tio Jorge. With these companions
and a small escort he left the city by the suburbs,
crossed the Ebro at Pina, and collecting on the way
about 1400 soldiers who had escaped from Madrid,
formed a junction at Belchite with Baron Versage and
some newly raised troops from Calatayud. Their
united numbers amounted to some 7000 men, with
100 horse and four pieces of artillery. Small as this
force was, and still more inefficient for want of
discipline than of numerical strength, Palafox resolved
upon making an attempt with it to succour the city.
The prudence of this determination was justly
questioned by some; others proposed the strange
measure of marching to Valencia: this probably
originated with some of the stray soldiers who were at
liberty to seek their fortune where they pleased, and
the proposal was so well received that a considerable
party prepared to set off in that direction, without
orders. But Palafox called them together, exhorted
them to do their duty, and offered passports to as
many as chose to leave him in the moment of danger.
The consequence of this offer was that not a man
departed. From Almunia, where he had rested a day,
he then marched towards Epila, thinking to advance
to the village of La Muela, and thus place the invaders
between his little army and the city, in the hope of
cutting them off from their reinforcements. Lefebvre
prevented this, by suddenly attacking him at Epila, on
the night of the 23d: after a most obstinate
resistance, the superior arms and discipline of the
French were successful. The wreck of this gallant
band retreated to Calatayud, and afterwards, with
great difficulty, threw themselves into Zaragoza.
G. Verdier joins The besiegers’ army was soon reinforced by
Lefebvre with General Verdier, with 2500 men, besides some
reinforcement. battalions of Portugueze, who, according to the
devilish system of Buonaparte’s tyranny, had been
forced out of their own country, to be pushed on in
the foremost ranks, wherever the first fire of a battery
was to be received, a line of bayonets clogged, or a
ditch filled, with bodies. They occupied the best
positions in the surrounding plain, and, on the 27th,
attacked the city and the Torrero; but they were
repulsed with the loss of 800 men, six pieces of
artillery, and five carts of ammunition. By this time,
they had invested nearly half the town. The next
morning they renewed the attack at both places; from
the city they were again repulsed, losing almost all
The Torrero the cavalry who were engaged. But the Torrero was
taken. lost through the alleged misconduct of an artillery
officer, who was charged with having made his men
abandon the batteries at the most critical moment.
For this he was condemned to run the gauntlet six
times, the soldiers beating him with their ramrods,
and after this cruelty he was shot.
The French The French, having now received a train of
bombard the mortars, howitzers, and twelve-pounders, which were
city. of sufficient calibre against mud walls, kept up a
constant fire, and showered down shells and grenades
from the Torrero. About twelve hundred were thrown
into the town, and there was not one building that
was bomb proof within the walls. After a time, the
inhabitants placed beams of timber together,
endways, against the houses, in a sloping direction,
behind which those who were near when a shell fell,
might shelter themselves. The enemy continued also
to invest the city more closely, while the Aragonese
made every effort to strengthen their means of
defence. They tore down the awnings from their
windows, and formed them into sacks, which they
filled with sand, and piled up before the gates, in the
form of a battery, digging round it a deep trench.
They broke holes for musketry in the walls and
intermediate buildings, and stationed cannon where
the position was favourable for it. The houses in the
environs were destroyed. “Gardens and olive
grounds,” says an eye-witness, “that in better times
had been the recreation and support of their owners,
were cheerfully rooted up by the proprietors
themselves, wherever they impeded the defence of
Exertions of the the city, or covered the approach of the enemy.”
women. Women of all ranks assisted; they formed themselves
into companies, some to relieve the wounded, some
to carry water, wine, and provisions, to those who
Countess defended the gates. The Countess Burita instituted a
Burita. corps for this service; she was young, delicate, and
beautiful. In the midst of the most tremendous fire of
shot and shells, she was seen coolly attending to
those occupations which were now become her duty;
nor throughout the whole of a two months’ siege did
the imminent danger, to which she incessantly
exposed herself, produce the slightest apparent effect
upon her, or in the slightest degree bend her from her
heroic purpose. Some of the monks bore arms; others
exercised their spiritual offices to the dying: others,
with the nuns, were busied in making cartridges
which the children distributed.
Among threescore thousand persons there will
always be found some wicked enough for any
employment, and the art of corrupting has constituted
great part of the French system of war. During the
night of the 28th the powder magazine, in the area
where the bull-fights were performed, which was in
the very heart of the city, was blown up, by which
fourteen houses were destroyed, and about 200
persons killed. This was the signal for the enemy to
appear before three gates which had been sold to
them. And while the inhabitants were digging out
their fellow-citizens from the ruins, a fire was opened
upon them with mortars, howitzers, and cannons,
which had now been received for battering the town.
Their attack seemed chiefly to be directed against the
gate called Portillo, and a large square building near
it, without the walls, and surrounded by a deep ditch;
though called a castle, it served only for a prison. The
sand-bag battery before this gate was frequently
destroyed, and as often reconstructed under the fire
Augustina of the enemy. The carnage here throughout the day
Zaragoza. was dreadful. Augustina Zaragoza, a handsome
woman of the lower class, about twenty-two years of
age, arrived at this battery with refreshments, at the
time when not a man who defended it was left alive,
so tremendous was the fire which the French kept up
against it. For a moment the citizens hesitated to re-
man the guns. Augustina sprung forward over the
dead and dying, snatched a match from the hand of a
dead artilleryman, and fired off a six-and-twenty
pounder; then, jumping upon the gun, made a solemn
vow never to quit it alive during the siege. Such a
sight could not but animate with fresh courage all
who beheld it. The Zaragozans rushed into the
battery, and renewed their fire with greater vigour
than ever, and the French were repulsed here, and at
all other points, with great slaughter. On the morning
of this day a fellow was detected going out of the city
with letters to Murat. It was not till after these
repeated proofs of treasonable practices, that the
French residents in Zaragoza, with other suspected
persons, were taken into custody.
The French Lefebvre now supposing that his destructive
again repulsed bombardment must have dismayed the people, and
in an attempt convinced them how impossible it was for so
to take the city defenceless a city to persist in withstanding him,
by storm. again attempted to force his way into the town,
thinking that, as soon as his troops could effect a
lodgement within the gates, the Zaragozans would
submit. On the 2d of July, a column of his army
marched out of their battery, which was almost within
musket-shot of the Portillo, and advanced towards it
with fixed bayonets, and without firing a shot. But
when they reached the castle, such a discharge of
grape and musketry was opened upon their flank,
that, notwithstanding the most spirited exertions of
their officers, the column immediately dispersed. The
remainder of their force had been drawn up to
support their attack, and follow them into the city; but
it was impossible to bring them a second time to the
charge. The general, however, ordered another
column instantly to advance against the gate of the
Carmen, on the left of the Portillo. This entrance was
defended by a sand-bag battery, and by musketeers,
who lined the walls on each side, and commanded
two out of three approaches to it; and here also the
French suffered great loss, and were repulsed.
They invest the The military men in Zaragoza considered these
city. attacks as extremely injudicious. Lefebvre probably
was so indignant at meeting with any opposition from
a people whom he despised, and a place which,
according to the rules and pedantry of war, was not
tenable, that he lost his temper, and thought to
subdue them the shortest way, by mere violence and
superior force. Having found his mistake, he
proceeded to invest the city still more closely. In the
beginning of the siege, the besieged received some
scanty succours; yet, however scanty, they were of
importance. Four hundred soldiers from the regiment
of Estremadura, small parties from other corps, and a
few artillerymen got in. Two hundred of the militia of
Logrono were added to these artillerymen, and soon
learnt their new service, being in the presence of an
enemy whom they had such righteous reason to
abhor. Two four-and-twenty-pounders and a few
shells, which were much wanted, were procured from
Lerida. The enemy, meantime, were amply supplied
with stores from the magazine in the citadel of
Pamplona, which they had so perfidiously seized on
their first entrance, as allies, into Spain. Hitherto they
6
had remained on the right bank of the Ebro. On the
11th of July they forced the passage of the ford, and
posted troops enough on the opposite side to protect
their workmen while forming a floating bridge. In
spite of all the efforts of the Aragonese, this bridge
1808. was completed on the 14th; a way was thus made for
July. their cavalry, to their superiority in which the French
They form a were mostly indebted for all their victories in Spain.
bridge over the This gave them the command of the surrounding
Ebro. country; they destroyed the mills, levied contributions
on the villages, and cut off every communication by
which the besieged had hitherto received supplies.
These new difficulties called out new resources in this
admirable people and their general, ... a man worthy
of commanding such a people in such times. Corn
mills, worked by horses, were erected in various parts
of the city; the monks were employed in
manufacturing gunpowder, materials for which were
obtained by immediately collecting all the sulphur in
the place, by washing the soil of the streets to extract
its nitre, and making charcoal from the stalks of
hemp, which in that part of Spain grows to a
magnitude that would elsewhere be thought very
7
unusual .
Distress of the By the end of July the city was completely
inhabitants. invested, the supply of food was scanty, and the
inhabitants had no reason to expect succour. Their
exertions had now been unremitted for forty-six days,
and nothing but the sense of duty could have
supported their bodily strength and their spirit under
such trials. They were in hourly expectation of
another general attack, or another bombardment.
They had not a single place of security for the sick
and the children, and the number of wounded was
daily increased by repeated skirmishes, in which they
engaged for the purpose of opening a communication
with the country. At this juncture they made one
desperate effort to recover the Torrero. It was in vain;
and convinced by repeated losses, and especially by
this last repulse, that it was hopeless to make any
effectual sally, they resolved to abide the issue of the
contest within the walls, and conquer or perish there.
Foundling On the night of the second of August, and on the
Hospital burnt. following day, the French bombarded the city from
1808. their batteries opposite the gate of the Carmen. A
August. foundling hospital, which was now filled with the sick
and wounded, took fire, and was rapidly consumed.
During this scene of horror, the most intrepid
exertions were made to rescue these helpless
sufferers from the flames. No person thought of his
own property or individual concerns, ... every one
hastened thither. The women were eminently
conspicuous in their exertions, regardless of the shot
and shells which fell about them, and braving the
flames of the building. It has often been remarked,
that the wickedness of women exceeds that of the
other sex; ... for the same reason, when
circumstances, forcing them out of the sphere of their
ordinary nature, compel them to exercise manly
virtues, they display them in the highest degree, and,
when they are once awakened to a sense of
patriotism, they carry the principle to its most heroic
pitch. The loss of women and boys, during this siege,
was very great, fully proportionate to that of men;
they were always the most forward, and the difficulty
was to teach them a prudent and proper sense of
their danger.
Convent of St. On the following day, the French completed their
Engracia. batteries upon the right bank of the Guerva, within
August 3. pistol-shot of the gate of St. Engracia, so called from
a splendid church and convent of Jeronimites, situated
on one side of it. This convent was, on many
accounts, a remarkable place. Men of letters beheld it
with reverence, because the excellent historian Zurita
spent the last years of his life there, observing the
rules of the community, though he had not entered
into the order; and because he was buried there, and
his countryman and fellow-labourer, Geronymo de
Blancas, after him. Devotees revered it, even in the
neighbourhood of our Lady of the Pillar, for its relics
and the saint to whom it was dedicated. According to
the legend, she was the daughter of Ont Comerus, a
barbarian chief, in the pay of the Romans, by whom
the city of Norba Cæsarea, (situated near the Tagus,
between the present towns of Portalegre and
Alcantara) was given him, together with its district, for
his service in recovering it from Cathelius, a chief of
the Alemanni. His daughter, Encratis, or Encratide,
(for from one of these names Engracia has been
formed) was brought up a Christian, and espoused to
a governor on the Gallic side of the Pyrenees, to
whom she was sent with a suitable escort. Their way
lay through Cæsarea-Augusta, where the Præses, or
Governor of Spain, Publius Dacianus, the bloodiest
minister of the tenth persecution, was at that time
endeavouring to extirpate Christianity. Engracia, either
preferring martyrdom to her unknown spouse, or
imagining that her rank would be her safeguard,
visited the governor for the purpose of interceding in
behalf of the Christians, and remonstrating against his
cruelty. Thus much of the legend is probably fabulous;
but certain it is, that a virgin of that name was
tortured under that persecution; and, though she
8
survived, was venerated as a martyr in that city,
before the close of the century in which she suffered.
Just, however, as her claim is to pious remembrance,
her church, and the divine honours which have been
paid to her, were procured by fraud. Angels are said
to have descended at her death, and to have
officiated at her funeral, bearing tapers and
thuribules, and singing hymns of triumph. During the
Moorish captivity, her relics disappeared; they were
discovered towards the close of the fourteenth
century, which was the great age for inventions of this
kind. There stood at that time, upon the site of this
memorable convent, an old church, dedicated to the
Zaragozan martyrs, of the tenth persecution, and
called the Iglesia de las Masas, in memory of an early
specimen of Catholic ingenuity. Dacianus, holding
relic-worship in as much contempt as the Christians
did his idolatry, in order to prevent them from
indulging in it, burnt the bodies of the martyrs,
together with those of some malefactors, thinking that
their ashes would be undistinguishable; nevertheless,
the Christians found their own, which had collected
together in white balls or masses, separate from the
rest. In 1389, the regular canons, to whom the church
belonged, resolved to rebuild a part of it: in digging
the foundation, two marble chests were discovered.
The lid of the smaller was fastened down very firmly
with a sort of pitch; when this was taken off, two sets
of human bones were found in different
compartments; over the one were the words Lupercii
Martyris, sculptured in the marble; over the other,
Engratiæ Virginis: these latter were of rose-colour,
which was admitted as proof of their authenticity. The
larger chest contained a great assortment of
anonymous bones, ashes, and the white masses,
which had disappeared for so many centuries. The
mine was very rich; the workmen went on till they
had invented thirteen chests, and at last, a whole pit
full of relics, not the less efficacious because it could
not be ascertained to whom they had belonged.
Seventy years afterwards, Juan II. of Aragon, one of
the wickedest and most perfidious of men, fancied or
feigned, that by St. Engracia’s intercession, he was
cured of a complaint in his eyes; in consequence of
which, he resolved to enlarge this church, and build a
monastery adjoining it for the Jeronimites, ... an order
which, during that and the succeeding age, was in
great favour at the three courts of the Peninsula. He
began his work, but died without completing it,
leaving that charge by will to his son, Ferdinand, the
Catholic king. He continued the building, but it was
not finished till the reign of Charles the Fifth.
Both the church and convent were splendidly
adorned, but the most remarkable part of the whole
edifice was a subterranean church, formed in the
place where the relics were discovered, and having
the pit, or well, as it was called, in the middle. It was
divided by a beautiful iron grating, which excluded
laymen from the interior of the sanctuary. There were
three descents; the widest flight of steps was that
which was for public use, the two others were for the
religioners, and met in one behind the three chief
altars, within the grating. Over the midst of these
altars were two tombs, placed one upon the other in a
niche; the under one containing the relics of
Engracia’s companions and fellows in martyrdom; the
upper, those of the saint herself, her head excepted,
which was kept in a silver shrine, having a collar of
precious stones, and enclosed in crystal. The altars on
either side had their respective relics; and several
others, equally rich in such treasures, were ranged
along the walls, without the grating. The roof was of
an azure colour, studded with stars to represent the
sky. The breadth of the vault considerably exceeded
its length; it was sixty feet wide, and only forty long.
Thirty little columns, of different marbles, supported
the roof. On the stone brink of the well, the history of
the Zaragozan martyrs was represented in bas-relief;
and an iron grating, reaching to the roof, secured it
from being profaned by idle curiosity, and from the
pious larcenies which it might otherwise have
tempted. Within this cage-work, a silver lamp was
suspended. Thirty such lamps were burning there day
and night; and, though the roof was little more than
twelve feet high, it was never in the slightest degree
9
sullied with smoke. The fact is certain ; but the useful
and important secret, by which oil was made to burn
without producing smoke, was carefully concealed;
and the Jeronimites continued till this time to exhibit a
miracle, which puzzled all who did not believe it to be
miraculous.
The hospital On the 4th of August, the French opened batteries
set on fire. within pistol-shot of this church and convent. The
mud walls were levelled at the first discharge; and the
besiegers rushing through the opening, took the
batteries before the adjacent gates in reverse. Here
General Mori, who had distinguished himself on many
former occasions, was made prisoner. The street of
St. Engracia, which they had thus entered, leads into
the Cozo, and the corner buildings where it thus
terminated, were on the one hand the convent of St.
Francisco, and on the other the General Hospital. Both
were stormed and set on fire; the sick and the
wounded threw themselves from the windows to
escape the flames, and the horror of the scene was
aggravated by the maniacs, whose voices raving or
singing in paroxysms of wilder madness, or crying in
vain to be set free, were heard amid the confusion of
dreadful sounds. Many fell victims to the fire, and
some to the indiscriminating fury of the assailants.
Those who escaped were conducted as prisoners to
the Torrero; but when their condition had been
discovered, they were sent back on the morrow, to
take their chance in the siege. After a severe contest
and dreadful carnage, the French forced their way
into the Cozo, in the very centre of the city, and,
before the day closed, were in possession of one half
of Zaragoza. Lefebvre now believed that he had
effected his purpose, and required Palafox to
surrender, in a note containing only these words:
10
“Head-quarters, St. Engracia. Capitulation !” The
heroic Spaniard immediately returned this reply:
11
“Head-quarters, Zaragoza. War at the knife’s point !”
War in the The contest which was now carried on is
streets. unexampled in history. One side of the Cozo, a street
about as wide as Pall-mall, was possessed by the
French; and, in the centre of it, their general, Verdier,
gave his orders from the Franciscan convent. The
opposite side was maintained by the Aragonese, who
threw up batteries at the openings of the cross
streets, within a few paces of those which the French
erected against them. The intervening space was
presently heaped with dead, either slain upon the
spot, or thrown out from the windows. Next day the
August 5. ammunition of the citizens began to fail; ... the French
were expected every moment to renew their efforts
for completing the conquest, and even this
circumstance occasioned no dismay, nor did any one
think of capitulation. One cry was heard from the
people, wherever Palafox rode among them, that, if
powder failed, they were ready to attack the enemy
with their knives, ... formidable weapons in the hands
The city of desperate men. Just before the day closed, Don
receives a Francisco Palafox, the general’s brother, entered the
reinforcement. city with a convoy of arms, and ammunition, and a
reinforcement of three thousand men, composed of
Spanish guards, Swiss, and volunteers of Aragon, ... a
succour as little expected by the Zaragozans, as it had
been provided against by the enemy.
P. Santiago The war was now continued from street to street,
Sass. from house to house, and from room to room; pride
and indignation having wrought up the French to a
pitch of obstinate fury, little inferior to the devoted
courage of the patriots. During the whole siege, no
man distinguished himself more remarkably than the
curate of one of the parishes, within the walls, by
name P. Santiago Sass. He was always to be seen in
the streets, sometimes fighting with the most
determined bravery against the enemies, not of his
country alone, but of freedom, and of all virtuous
principles, wherever they were to be found; at other
times, administering the sacrament to the dying, and
confirming, with the authority of faith, that hope,
which gives to death, under such circumstances, the
joy, the exultation, the triumph, and the spirit of
martyrdom. Palafox reposed the utmost confidence in
this brave priest, and selected him whenever any
thing peculiarly difficult or hazardous was to be done.
At the head of forty chosen men, he succeeded in
introducing a supply of powder into the town, so
essentially necessary for its defence.
This most obstinate and murderous contest was
continued for eleven successive days and nights, more
indeed by night than by day; for it was almost certain
death to appear by daylight within reach of those
houses which were occupied by the other party. But
under cover of the darkness, the combatants
frequently dashed across the street to attack each
other’s batteries; and the battles which began there,
were often carried on into the houses beyond, where
they fought from room to room, and floor to floor. The
hostile batteries were so near each other, that a
Spaniard in one place made way under cover of the
dead bodies, which completely filled the space
between them, and fastened a rope to one of the
French cannons; in the struggle which ensued, the
rope broke, and the Zaragozans lost their prize at the
very moment when they thought themselves sure of
12
it .
Number of the A new horror was added to the dreadful
dead. circumstances of war in this ever memorable siege. In
general engagements the dead are left upon the field
of battle, and the survivors remove to clear ground
and an untainted atmosphere; but here ... in Spain,
and in the month of August, there where the dead lay
the struggle was still carried on, and pestilence was
dreaded from the enormous accumulation of
putrifying bodies. Nothing in the whole course of the
siege so much embarrassed Palafox as this evil. The
only remedy was to tie ropes to the French prisoners,
and push them forward amid the dead and dying, to
remove the bodies, and bring them away for
interment. Even for this necessary office there was no
truce, and it would have been certain death to the
Aragonese who should have attempted to perform it;
but the prisoners were in general secured by the pity
of their own soldiers, and in this manner the evil was,
in some degree, diminished.
Retreat of the A council of war was held by the Spaniards on the
enemy. 8th, not for the purpose which is too usual in such
councils, but that their heroic resolution might be
communicated with authority to the people. It was,
that in those quarters of the city where the Aragonese
still maintained their ground, they should continue to
defend themselves with the same firmness: should
the enemy at last prevail, they were then to retire
over the Ebro into the suburbs, break down the
bridge, and defend the suburbs till they perished.
When this resolution was made public, it was received
with the loudest acclamations. But in every conflict
the citizens now gained ground upon the soldiers,
winning it inch by inch, till the space occupied by the
enemy, which on the day of their entrance was nearly
half the city, was gradually reduced to about an eighth
part. Meantime, intelligence of the events in other
parts of Spain was received by the French, ... all
tending to dishearten them; the surrender of Dupont,
the failure of Moncey before Valencia, and the news
that the Junta of that province had dispatched six
thousand men to join the levies in Aragon, which were
destined to relieve Zaragoza. During the night of the
13th, their fire was particularly fierce and destructive;
after their batteries had ceased, flames burst out in
many parts of the buildings which they had won; their
last act was to blow up the church of St. Engracia; the
powder was placed in the subterranean church, ...
and this remarkable place, ... this monument of fraud
and of credulity, ... the splendid theatre wherein so
many feelings of deep devotion had been excited, ...
which so many thousands had visited in faith, and
from which unquestionably many had departed with
their imaginations elevated, their principles ennobled,
and their hearts strengthened, was laid in ruins. In
the morning the French columns, to the great surprise
of the Spaniards, were seen at a distance, retreating
over the plain, on the road to Pamplona.
The history of a battle, however skilfully narrated,
is necessarily uninteresting to all except military men;
but in the detail of a siege, when time has destroyed
those considerations, which prejudice or pervert our
natural sense of right and wrong, every reader
sympathizes with the besieged, and nothing, even in
fictitious narratives, excites so deep and animating an
interest. There is not, either in the annals of ancient
or of modern times, a single event recorded more
worthy to be held in admiration, now and for
evermore, than the siege of Zaragoza. Will it be said
that this devoted people obtained for themselves, by
all this heroism and all these sacrifices, nothing more
than a short respite from their fate? Woe be to the
slavish heart that conceives the thought, and shame
to the base tongue that gives it utterance! They
purchased for themselves an everlasting
remembrance upon earth, ... a place in the memory
and love of all good men in all ages that are yet to
come. They performed their duty; they redeemed
their souls from the yoke; they left an example to
their country, never to be forgotten, never to be out
of mind, and sure to contribute to and hasten its
deliverance.
One of the first cares of Palafox, after the delivery
of the city, was, to establish a board of health to
provide against the effects of putrefaction, ... such
was the number of French who were left dead in the
houses and in the streets. Pamplona, whither the
wreck of their army retreated, was for many days
filled with carts full and horse-loads of wounded, who
arrived faster and in greater number than they could
be lodged in the hospitals and convents. It was
equally shocking to humanity to behold their
sufferings, and the cruel regardlessness of their
comrades, who, while these wretches were fainting
for want of assistance and of food, and literally dying
in the streets, were exposing their booty to sale, and
courting purchasers for church plate, watches, jewels,
linen, and apparel, the plunder which they had
collected in Navarre and Aragon; and which, in their
eagerness to convert into money, they were offering
at a small part of their value. There were, however,
scarcely any purchasers except for the church plate,
which was bought for the purpose of restoring it, at
the same cost, to the churches and monasteries from
whence it had been stolen.
The temper of the Zaragozans after their victory
was not less heroic than their conduct during the
struggle. It might have been expected that some
degree of exhaustion would have succeeded the state
of excitement to which they had been wrought; and
that the widowed, the childless, and they who were
left destitute, would now have lamented what they
had lost, or, at least, that they themselves had not
perished also. This, however, was not so. Mr. Vaughan
visited Zaragoza a little while after the siege, and
remained there during several weeks: he saw (they
are his own impressive words) “many a parent who
had lost his children, and many a man reduced from
competence to poverty, but he literally did not meet
with one human being who uttered the slightest
complaint: every feeling seemed to be swallowed up
in the memory of what they had recently done, and in
a just hatred of the French.” These are the effects of
patriotism, aided and strengthened by religion: its
influence, thus elevated and confirmed, made women
and boys efficient in the time of action, and the
streets of a city not less formidable to an invader than
the best constructed works of defence. Let not the
faith which animated the Aragonese be called
superstition, because our Lady of the Pillar, Santiago,
and St. Engracia, were its symbols. It was virtually
and essentially religion in its inward life and spirit; it
was the sense of what they owed equally to their
forefathers and their children; the knowledge that
their cause was as righteous as any for which an
injured and insulted people ever rose in arms; the
hope that by the blessing of God upon that cause they
might succeed; the certain faith that if they fell, it was
with the feeling, the motive, and the merit of
martyrdom. Life or death therefore became to the
Zaragozans only not indifferent, because life was
useful to the cause for which they held it in trust, and
were ready to lay it down: they who fell expired in
triumph, and the survivors rather envied than
regretted them. The living had no fears for
themselves, and for the same reason they could have
no sorrows for the dead. The whole greatness of our
nature was called forth, ... a power which had lain
dormant, and of which the possessors themselves had
not suspected the existence, till it manifested itself in
the hour of trial.
When the dead were removed, and the ruins
sufficiently cleared, Ferdinand was proclaimed with all
August 20. the usual solemnities; a ceremony, at other times
attended with no other feeling than such as sports
and festivity occasion, now made affecting by the
situation of Ferdinand himself, and the scene which
surrounded the spectators; walls blackened with fire,
shattered with artillery, and stained with blood. The
August 25. obsequies of the Spaniards who had fallen were next
performed with military honours, and their funeral
oration pronounced from the pulpit. The brave priest
Santiago Sass was made chaplain to the commander
in chief, and Palafox gave him a captain’s commission.
These were times when the religion of Mattathias and
the Maccabees was required; and the priest of the
altar was in the exercise of his duty, when defending
it, sword in hand, in the field. A pension was settled
upon Augustina, and the daily pay of an artilleryman.
She was also to wear a small shield of honour
embroidered upon the sleeve of her gown, with
Zaragoza inscribed upon it. Tio Jorge was killed during
the siege. Other persons, who had distinguished
themselves, were rewarded; and the general reward
which Palafox conferred upon the Zaragozan people,
is strongly characteristic of Spanish feeling. By his
Sept. 20. own authority, and in the name of Ferdinand, he
conferred upon all the inhabitants of the city and its
districts, of both sexes and of all ranks, the perpetual
and irrevocable privilege of never being adjudged to
any disgraceful punishment by any tribunal for any
offence, except for treason or blasphemy.
CHAPTER X.
INSURRECTION IN PORTUGAL.
ebookgate.com