Docs Help

Terms, Icons, and Labels

Many classes have shortcut names used when creating (instantiating) a class with a configuration object. The shortcut name is referred to as an alias (or xtype if the class extends Ext.Component). The alias/xtype is listed next to the class name of applicable classes for quick reference.

Access Levels

Framework classes or their members may be specified as private or protected. Else, the class / member is public. Public, protected, and private are access descriptors used to convey how and when the class or class member should be used.

Member Types

Member Syntax

Below is an example class member that we can disect to show the syntax of a class member (the lookupComponent method as viewed from the Ext.button.Button class in this case).

lookupComponent ( item ) : Ext.Component
protected

Called when a raw config object is added to this container either during initialization of the items config, or when new items are added), or {@link #insert inserted.

This method converts the passed object into an instanced child component.

This may be overridden in subclasses when special processing needs to be applied to child creation.

Parameters

item :  Object

The config object being added.

Returns
Ext.Component

The component to be added.

Let's look at each part of the member row:

Member Flags

The API documentation uses a number of flags to further commnicate the class member's function and intent. The label may be represented by a text label, an abbreviation, or an icon.

Class Icons

- Indicates a framework class

- A singleton framework class. *See the singleton flag for more information

- A component-type framework class (any class within the Ext JS framework that extends Ext.Component)

- Indicates that the class, member, or guide is new in the currently viewed version

Member Icons

- Indicates a class member of type config

- Indicates a class member of type property

- Indicates a class member of type method

- Indicates a class member of type event

- Indicates a class member of type theme variable

- Indicates a class member of type theme mixin

- Indicates that the class, member, or guide is new in the currently viewed version

Class Member Quick-Nav Menu

Just below the class name on an API doc page is a row of buttons corresponding to the types of members owned by the current class. Each button shows a count of members by type (this count is updated as filters are applied). Clicking the button will navigate you to that member section. Hovering over the member-type button will reveal a popup menu of all members of that type for quick navigation.

Getter and Setter Methods

Getting and setter methods that correlate to a class config option will show up in the methods section as well as in the configs section of both the API doc and the member-type menus just beneath the config they work with. The getter and setter method documentation will be found in the config row for easy reference.

History Bar

Your page history is kept in localstorage and displayed (using the available real estate) just below the top title bar. By default, the only search results shown are the pages matching the product / version you're currently viewing. You can expand what is displayed by clicking on the button on the right-hand side of the history bar and choosing the "All" radio option. This will show all recent pages in the history bar for all products / versions.

Within the history config menu you will also see a listing of your recent page visits. The results are filtered by the "Current Product / Version" and "All" radio options. Clicking on the button will clear the history bar as well as the history kept in local storage.

If "All" is selected in the history config menu the checkbox option for "Show product details in the history bar" will be enabled. When checked, the product/version for each historic page will show alongside the page name in the history bar. Hovering the cursor over the page names in the history bar will also show the product/version as a tooltip.

Search and Filters

Both API docs and guides can be searched for using the search field at the top of the page.

On API doc pages there is also a filter input field that filters the member rows using the filter string. In addition to filtering by string you can filter the class members by access level, inheritance, and read only. This is done using the checkboxes at the top of the page.

The checkbox at the bottom of the API class navigation tree filters the class list to include or exclude private classes.

Clicking on an empty search field will show your last 10 searches for quick navigation.

API Doc Class Metadata

Each API doc page (with the exception of Javascript primitives pages) has a menu view of metadata relating to that class. This metadata view will have one or more of the following:

Expanding and Collapsing Examples and Class Members

Runnable examples (Fiddles) are expanded on a page by default. You can collapse and expand example code blocks individually using the arrow on the top-left of the code block. You can also toggle the collapse state of all examples using the toggle button on the top-right of the page. The toggle-all state will be remembered between page loads.

Class members are collapsed on a page by default. You can expand and collapse members using the arrow icon on the left of the member row or globally using the expand / collapse all toggle button top-right.

Desktop -vs- Mobile View

Viewing the docs on narrower screens or browsers will result in a view optimized for a smaller form factor. The primary differences between the desktop and "mobile" view are:

Viewing the Class Source

The class source can be viewed by clicking on the class name at the top of an API doc page. The source for class members can be viewed by clicking on the "view source" link on the right-hand side of the member row.

Sencha Touch 2.4


top

Using and Creating Builds

Sencha Touch comes with a class system that features the ability to dynamically load classes when they are needed. This approach has many benefits in both development and production.

In development, dynamic loading means that you get a file-by-file stack trace, which makes it much easier to debug problems with your application. For production, we provide a build tool that enables you to easily create a minified custom build that only includes the classes your app actually uses, meaning loading times are often reduced for your users.

Note: You can use the sencha app build [-run] native build commands with Cordova or PhoneGap if you first initialize these features with either the sencha cordova init or sencha phonegap init commands.

For more information, see Cordova and PhoneGap Apps.

Choosing a Build

Sencha Touch ships with five builds out of the box. If you want to get up and running as quickly as possible, it is best to use sencha-touch-debug.js while developing your app locally, then switch to sencha-touch.js in production. The other three builds are good for debugging in production, running in production without a custom build, and migrating your Touch 1.x app to 2.x.

Because each build is used for a different purpose and is created using a different set of build options, we have created a table that details the configuration of each one:

Name Type Loader Minified Comments Debug Compat Usage
sencha-touch-debug.js Core Use when developing your app locally
sencha-touch.js Core Use in production with a custom build
sencha-touch-all.js All Use in production if you don't have a custom build
sencha-touch-all-debug.js All Use to debug your app in staging/production
builds/sencha-touch-all-compat.js All Use to migrate your 1.x app to 2.x

Note: Only sencha-touch-all-compat.js is contained within the 'builds' directory in the SDK download. The following list provides additional detail on each option:

  • Type: Either "Core" or "All" - Core includes the base classes but none of the Components, All means everything is included
  • Loader: Whether dynamic loading is activated or not. Only sencha-touch-debug.js has this activated by default
  • Minified: Indicates that the build has been compressed with a YUI (Yahoo user interface) compressor
  • Comments: Indicates that the build still contains the JSDoc comments (these are usually stripped in production to speed up downloads)
  • Debug: Indicates that the build provides debug messages, such as if you misconfigured a class
  • Compat: Indicates that the code provides backwards compatibility in the build with Sencha Touch 1.x

Use sencha-touch-debug.js in development mode, then in production switch to either sencha-touch.js or sencha-touch-all.js plus a custom build.

Creating Your Own Build

In the vast majority of cases a Sencha Touch app should use a custom build in production, for two main reasons:

  1. Custom builds include only the framework classes that your app is actually using, saving on download time
  2. A custom build includes all of your app classes in a single file, which translates into a single network request

For deployed applications, the second reason is most important. Since most applications have a large number of files (sometimes hundreds), loading them one by one, especially over a mobile connection, can take a long time. Each request can add several hundred milliseconds of delay which can easily add several seconds to your application's overall load time.

To load your applications quickly in a production environment, use Sencha's command line build tool, Sencha Cmd, which:

  1. Determines framework classes your application uses
  2. Loads application classes when your application starts
  3. Combines all of classes into a single file, with the classes in the correct order
  4. Strips out all of the JSDoc comments and minifies the file to be as small as possible

Installing Sencha Cmd

Ensure that you download and install Sencha Cmd.

Generating a Build

We are going to assume that you have an app that already works locally and that you just want to build it for production. If you do not have an app yet, or, do not know how to create one, check out the Getting Started guide.

Assuming that your app works locally, let us proceed. To illustrate how this works, we are going to use the Twitter example that comes with the Sencha Touch SDK. Take a look at the example's index.html file:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Twitter</title>

    <link rel="stylesheet" href="resources/css/application.css" type="text/css">

    <script type="text/javascript" src="touch/sencha-touch-debug.js"></script>
    <script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>

Note: We load sencha-touch-debug.js and app.js, which allows us to use dynamic loading while developing our app. This is the basis for the Sencha Cmd's ability to generate a minimal build.

At the command line, change directory to the hard drive directory that contains your app:

cd ~/path/to/my/app

To generate a build compatible with the native packager, use one of the following:

  • sencha app build native
    • Builds the app and prepares a file called packager.temp.json that you can use to package an application--the packager.temp.json is the same as packager.json, but contains additional paths. Use the sencha app package run packager.temp.json command to run the packager and launch a simulator.
  • sencha app build -run native

    • Builds and automatically packages the application, and launches the appropriate simulator
  • sencha app build package

    • Builds the app with packaging support, but does not configure a packager JSON file.
      This is useful for projects that manually maintain multiple packager.json files (android.json, ios.json, etc.).

    • Useful for continuous integration builds where the build may be run once, then packaged multiple times, for example:

      • sencha app build package
      • sencha app package build android.json
      • sencha app package build ios.json

Note: You can use the "sencha app build [-run] native" commands with Cordova or PhoneGap if you first initialize these features with either the sencha cordova init or sencha phonegap init commands. For more information, see Cordova and PhoneGap Apps.

Updating your HTML file

The final step for preparing your app for production is to update your HTML file to use sencha-touch.js instead of sencha-touch-debug.js, and to load your newly-generated all-classes.js file. The twitter example file ends up as follows:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Twitter</title>

    <link rel="stylesheet" href="resources/css/application.css" type="text/css">

    <script type="text/javascript" src="touch/sencha-touch.js"></script>
    <script type="text/javascript" src="all-classes.js"></script>
    <script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>

Rather than change your main index.html file all the time, it is common to create a duplicate called index-production.html that looks like the previous file. Many developers produce a simple deploy script that automatically copies the app into a deploy folder and rename index-production.html to index.html, such that the build can be uploaded.

Sencha Touch 2.4