Preface

The world of JavaScript frameworks is a ground in constant motion. New libraries and packages are published nearly every day, but as in any other market, only a few of them strive to attain a relatively large audience, reaching millions of downloads and, in some cases, some sort of cult following.

Sencha Touch is, without any doubt, one of the most talked-about of those frameworks—sometimes loved, sometimes hated, but never ignored. Released to the public in 2010 after two years in the making, it is in many respects the most advanced touchscreen-enabled JavaScript framework available today. It is also a daunting platform, with an incredible amount of functionality baked in, covering almost every possible requirement in the process of developing mobile applications.

This book hopes to provide a meaningful, simple path to approach the complexity encapsulated in this system, allowing developers to create mobile applications for iOS, Android, and BlackBerry devices.

Intended Audience

This book is a general introduction to the Sencha Touch framework and platform, intended for mobile developers familiar with either iOS or Android who have an intermediate or advanced level of knowledge of JavaScript.

Structure of this Book

The book is structured as follows:

  • Chapter 1, “Getting Started,” provides a complete overview of the framework. Developers who are in a hurry or who want to get down to the code can read this chapter to get a feeling of what the platform is capable of.
  • Chapter 2, “The Class System,” starts with a discussion of the particular flavor of the model-view-controller (MVC) architecture used and enforced by Sencha Touch applications. It provides an introduction to the class definition and instantiation paradigm, and finally it contains an extensive review of low-level foundation code provided by the framework (data structures, algorithms, application programming interfaces [APIs], etc.)
  • Chapter 3, “Views,” contains a description of the extensive library of visual components provided by Sencha Touch, including examples and sample code. It also discusses the approach required to create your own components from scratch.
  • Chapter 4, “Data,” explains in detail how to define and use model classes in your applications, including a discussion of the whole infrastructure of stores, proxies, validations, and associations.
  • Chapter 5, “Forms,” builds upon the previous two chapters to discuss in detail the creation and use of complex forms in applications, including a complete description of every type of form field available.
  • Chapter 6, “Controllers,” provides the final elements of the Sencha Touch MVC architecture, explaining how to encapsulate business logic using controller objects, highlighting the benefits of this approach.
  • Chapter 7, “Styling Applications,” explains how to use Sass to embellish and give a unique visual personality to applications, including a reference to the most important variables and elements that can be modified by application designers.
  • Chapter 8, “Debugging, Testing, and Documenting,” shows how to increase the quality of Sencha Touch applications using tools such as the WebKit Web Inspector, Jasmine, Siesta, and JSDuck.
  • Chapter 9, “Sencha Architect,” provides an introduction to this commercial tool that provides both an integrated development environment (IDE) and a visual application designer canvas, used for rapid application development.
  • Finally, Chapter 10, “Deployment in Devices,” explains how to distribute Sencha Touch applications in production, either as HTML5 offline apps or as standalone native apps for iOS and Android, to be sold through the respective marketplaces of those platforms.

Code of the Book

You can download all the code samples of this book from Github. The project contains an installation script named install.sh that will download all the required libraries for the samples to run. The code of the book is distributed using a liberal Berkeley Source Distribution (BSD) license, and will be updated to reflect any changes and updates to Sencha Touch 2.x.

Note

Please be aware that the code samples are meant to be run from a web server, and not just by double-clicking and opening the index.html file in your browser directly. This is because Sencha Touch uses the XMLHTTPRequest object, which cannot be used when opening files using the file:/// protocol.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This icon signifies a tip, suggestion, or general note.

Warning

This icon indicates a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, if this book includes code examples, 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: “Sencha Touch 2 Up and Running by Adrian Kosmaczewski (O’Reilly). Copyright 2013 Adrian Kosmaczewski, 978-1-449-33938-8.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online

Note

Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

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://oreil.ly/sencha_touch_2.

To comment or ask technical questions about this book, send email to .

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

Acknowledgments

The idea for this book came as soon as my previous one, Mobile JavaScript Application Development went to press. In that book I had included a short introduction to Sencha Touch, and writing that chapter was such an enjoyable experience that I thought a full book on the subject was a worthy goal.

Frederick Brooks famously explained the consequences of the “second-system effect,” where small, successful systems have absolutely monstrous successors; I can say that this book suffered from a similar pathology, maybe because I wrote it amid one of the most complex and difficult times of my life.

Because of this context, this second book would never have been possible without the great help of lots of incredible people scattered all over the planet: to begin with, the whole Sencha team, who have created and documented an out-of-this-planet kind of JavaScript framework; kudos and thanks to all of them, in particular to Jeff Hartley, vice president of services; to David Marsland, chief instructor; and Jim Soper, senior technical trainer at Sencha.

I would also like to thank Simon St. Laurent, my editor at O’Reilly, who wholeheartedly embraced the idea of this book just as we were sending Mobile JavaScript Application Development to press, and was extremely supportive during the process. I would also like to thank the reviewers of this book: Jens-Christian Fischer, from Zurich, Switzerland, with whom I had the privilege of teaching Sencha Touch in the past, and who has provided me with incredible tips and tricks to make this book a better one; Mats Bryntse, founder of Bryntum AB from Lund, Sweden, creator of the Siesta testing framework described in Chapter 8, and who reviewed that chapter extensively; Gabriel García Marengo, web designer at IMD in Lausanne, Switzerland, who sent great feedback, and who is one of the best friends anyone could have; Martín Paoletta, solutions architect at Redbee in Buenos Aires, Argentina, who read the book from the perspective of a solution provider and made excellent recommendations. Thanks to you all.

Get Sencha Touch 2 Up and Running now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.