- Aug 3, 2011
Building a jQuery Mobile Page
Before walking you through the process of generating a mobile-friendly, jQuery Mobilebased page in Dreamweaver, let me share a couple of orienting thoughts:
- On one hand, the process of generating a mobile-friendly page using jQuery Mobile elements is almost too easy to justify reading an article about it.
- On the other hand, along the way you'll encounter a variety of options and choices, the implications of which are far from intuitive.
Having tried every option (good, bad, and otherwise), I'll do my best to make this a guided tour of the process.
I promised you a guided tour of the process of generating mobile pages with Dreamweaver CS5.5. That requires a bit of previous orientation.
In advance of generating mobile pages, you should do some things that are standard to working with any web page in Dreamweaver CS5.5or Dreamweaver in general. In addition, some particular steps will assist you in creating mobile pages with jQuery Mobile.
As with anything you do in any version of Dreamweaver, the first step in generating mobile pages with jQuery Mobile is to define and work in a Dreamweaver site. I walk through this process in many available articles, books, and videos (the most comprehensive and best discussion being in Adobe Creative Suite 5 Web Premium How-Tos: 100 Essential Techniques), so I won't repeat those basics here.
Before anything else we do, let me emphasize again that defining and working in a Dreamweaver site is essential to generating jQuery Mobile pages. However, it's not necessary to define a remote server connection as part of your site definition; a local site is all you need. If you don't already have an open site, choose Site > New Site, and then define the site name and the local root folder. Defining useful sites takes a few more steps, but the basics I've discussed so far should allow you to follow the remaining instructions for creating a mobile page.
jQuery Mobile CSS
jQuery Mobile pages require a very complex CSS file, with CSS classes (that is, stylesheet class styles) for every object used in the interactive and animated objects on a mobile page. jQuery Mobile pages won't work unless this stylesheet is linked to the page. You shouldn't create this CSS stylesheet file yourself, unless you're a committed masochist. Instead, we'll use a standardized CSS file. Where does that leave you in terms of designing creative and unique web pages? That major challenge is mostly beyond the realm of this article; I'll address it in an upcoming book. For right now, simply note a couple of things:
- Mobile web pages are pretty simple and basic; there isn't a lot of room for creative design.
- jQuery Mobile comes with a handful of preset themes you can use for controlling color schemes.
Obviously, neither of these options is fully acceptable for a creative designer aspiring to develop a really unique mobile site, but we'll live with that constraint in this article, and in coming articles I'll write quite a bit about solving this challenge.
On a practical level, the challenge is this: Where do you get this "standardized CSS file"? Dreamweaver provides two options, neither of which I consider quite acceptable without a bit of a workaround:
- Link directly to the remote version of the CSS file used for jQuery Mobile elements. The problem with this option is that it makes customizing the CSS on the page more difficult. As I mentioned earlier, customizing with jQuery Mobile can be a bit of a hassle, but it is possible, and you don't want to make it harder than it has to be.
- Use a local version of the CSS file that's built into Dreamweaver CS5.5. The problem here is that the CSS file that's built into Dreamweaver CS5.5 might be out of date by the time you use it. I've also found it to be easily changeable, meaning that when you do edit the file, it remains edited, and you can't restore the original unedited version.
Let me explain this issue in a bit more detail. To make this whole setup work, a particular jQuery Mobilerelated CSS stylesheet file is required. If you changed that file in a way that rendered it dysfunctional, you would mess up the whole jQuery Mobile setup that relies on the file. Now suppose that instead of keeping that CSS styles file locally, you link to a clean version of the file at a remote siteone maintained by the jQuery folks. You can't change that remote file, so it's guaranteed to work correctly.
Of course, the downside to relying on the remote version of the required CSS file is that you can't customize it at all. You can't mess it up, and thus undo the whole set of linked files making jQuery Mobile objects work, but you also can't personalize it.
Here's my suggested solution: Go and get the current CSS file. Do it right nowor at least before you start working on your site. Copy-and-paste that page full of CSS code into a new CSS file in Dreamweaver CS5.5, and save it in the root folder of your site as jq.css. (Your coffee will still be hot when you're finished.)
Now you have a local versionthe latest versionof the CSS file that's required for jQuery Mobile elements. You even know where to get it again if you ever need it.
With your site defined and the jq.css file saved to the root folder of your local site, you're ready to follow the steps in the rest of this article to generate a jQuery Mobilebased page.