Authors:Sébastien Le Ray
Developers:multiple developers

Deprecated. Since V1.8, use dojox/app instead. provides a simple framework to develop mobile web applications. It handles view definitions and resources in a declarative fashion.


First, you’ve to create a basic front page that will initialize information and starts the framework.

<!DOCTYPE HTML PUBLIC "-// W3C// DTD HTML 4.01// EN" "">
    <!-- this should be dynamically generated -->
    <link href="/js/dojox/mobile/themes/iphone/iphone-app.css" rel="stylesheet">
    <script type="text/javascript" src="/js/dojo/dojo.js" ></script>
    <script type="text/javascript" src="/js/dojox/mobile/app.js"></script>
    <script language="JavaScript" type="text/javascript">
      dojo.requireIf(!dojo.isWebKit, "");

      var appInfo = {
        id: "com.mycompany.myapp",
        title: "My Mobile application"


Note that all JS inclusions are static because some browsers may fail on dojo.require (no support for sync XMLHttpRequest). The included theme stylesheet should depend on user-agent (server side work).

This simple examples defines an application whose main scene is “main”. When calling, the framework will try to fetch the scene template and its JS initialization code. By default templates are under app/views/[scene]/[scene]-scene.html and “Assistants” (that is, JS initialization code) is under app/assistants/[scene]-assistant.js. If you want to modify this, you’ll have to re-declare and

To load an initial scene other than ‘main’, set the ‘initialScene’ value in appInfo to the name of that scene, e.g.

var appInfo = {
        id: "com.mycompany.myapp",
        title: "My Mobile application",
        initialScene: 'mycustomscene'

View resources

Application view resources are all JavaScript files needed to run the application. They should be accessible through view-resources.json under the same directory as the initialization page. It should provide an array of objects under the form of [ { scene: '', source: 'url', module: '' }, ... ]. If source is set, it will be treated as an URL and fetched directly, if module is set it will be treated as a classic module name and transformed accordingly (dots become slashes and .js added). If no scene is specified, resource will be loaded at application startup, otherwise it will be loaded when a given scene is requested.

You should use view resources instead of dojo.require to support browsers without synchronous XMLHttpRequest.

Assistants do not have to be specified as view resource. They’re implicitly loaded with each view.


Scenes are simply HTML templates, they will not be parsed for widget automatically, you’ll have to handle this in the scene assistant.


Each view should come with an assistant, which is responsible for the JS setup of the scene. It must extend which provides three methods:

  • setup(): called once the scene has been loaded but not displayed. If you want to parse your view, you’ll have to do it there through the parse() method of the controller field of the assistant;
  • activate(data): called every time the view is made visible. Data will contains optional data transmitted by the previous view;
  • deactivate(): called each time the view is hidden and when it is destroyed.

You can access to the SceneController of the assistant’s scene through its field controller, e.g. from any scene assistant use this.controller.


SceneController provides utilities for a scene assistant, and also takes care of instantiating an assistant and calling it’s lifecycle methods. Assistants have a field controller which is set to their scene’s controller.

  • parse((optional)node): Parses the current scene for widgets. As all scenes reside in the same DOM, you cannot call dojo.parser.parse() directly or you may instantiate widgets twice;
  • query(selector, (optional)node): calls dojo.query ensuring that results will belongs to the controller’s scene if no node is provided;
  • showAlertDialog({title: '', text: '', buttons: [{btnClass: 'cssClass', label: ''}], defaultButtonLabel: '', onChose: function(pressedButton){} }): Display an alert dialog, if no buttons are provided, a simple “OK” one is created. You can alternatively show an alert dialog from anywhere by calling dojo.publish(“/dojox/mobile/app/alert”, params), where the params variable is the same as that passed to showAlertDialog;
  • popupSubMenu({ choices: [{className: 'cssClass', label: '', value: ''}], onChoose: function(value){}, fromNode: node}): display a popup menu whose entries are choices. onChoose with the selected value. If fromNode is null, menu will be displayed roughly on the top of the screen.


Stage controller handle global application behavior and thus provide various application level methods. The application StageController is available through or the stageController property of a SceneController.

  • pushScene(sceneName, params): Loads and execute scene sceneName. params will be passed to the Assistant constructor, and also to the Assistant’s activate() method the first time it is called. Transition effect between scenes can be controlled through the effect attribute of the StageController or predefined using dojoConfig.mobileAnim property;
  • popScene(data): goes back to the scene we were before the current one (if any). data will be passed to the activate method of the scene. You can alternatively use dojo.publish to pop a scene, without needing access to the StageController, by calling dojo.publish(“/dojox/mobile/app/goback”);
  • popScenesTo(sceneName, data): “rewinds” the scenes until the current one is sceneName.
Error in the documentation? Can’t find what you are looking for? Let us know!