dojox/mobile/ViewController (version 1.10)

Summary

A singleton class that controls view transition.

This class listens to the "startTransition" events and performs view transitions. If the transition destination is an external view specified with the url parameter, the view content is retrieved and parsed to create a new target view.

Usage

var foo = new ViewController();
dojox/mobile/ViewController

See the dojox/mobile/ViewController reference documentation for more information.

Property Summary

  • _instance
  • dataHandlerClassThe data handler class used to load external views, by default "dojox/mobile/dh/DataHandler" (see the Data Handlers page in the reference documentation).
  • dataSourceClassThe data source class used to load external views, by default "dojox/mobile/dh/UrlDataSource" (see the Data Handlers page in the reference documentation).
  • fileTypeMapClassThe file type map class used to load external views, by default "dojox/mobile/dh/SuffixFileTypeMap" (see the Data Handlers page in the reference documentation).

Method Summary

Event Summary

Properties

_instance
dataHandlerClass

The data handler class used to load external views, by default "dojox/mobile/dh/DataHandler" (see the Data Handlers page in the reference documentation).

dataSourceClass

The data source class used to load external views, by default "dojox/mobile/dh/UrlDataSource" (see the Data Handlers page in the reference documentation).

fileTypeMapClass

The file type map class used to load external views, by default "dojox/mobile/dh/SuffixFileTypeMap" (see the Data Handlers page in the reference documentation).

Methods

findTransitionViews(moveTo)

Parses the moveTo argument and determines a starting view and a destination view.

Parameter Type Description
moveTo String
Returns:Array

An array containing the currently showing view, the destination view and the transition parameters, or an empty array if the moveTo argument could not be parsed.

getInstance()
openExternalView(transOpts,target)

Loads an external view and performs a transition to it.

This method loads external view content through the dojox/mobile data handlers, creates a new View instance with the loaded content, and performs a view transition to the new view. The external view content can be specified with the url property of transOpts. The new view is created under a DOM node specified by target.

Parameter Type Description
transOpts Object
target DomNode
Returns:dojo/_base/Deferred | instance

Deferred object that resolves when the external view is ready and a transition starts. Note that it resolves before the transition is complete.

Examples

Example 1

This example loads view1.html, creates a new view under <body>, and performs a transition to the new view with the slide animation.

var vc = ViewController.getInstance();
vc.openExternalView({
    url: "view1.html", 
    transition: "slide"
}, win.body());

Example 2

If you want to perform a view transition without animation, you can give transition:"none" to transOpts.

var vc = ViewController.getInstance();
vc.openExternalView({
    url: "view1.html", 
    transition: "none"
}, win.body());

Example 3

If you want to dynamically create an external view, but do not want to perform a view transition to it, you can give noTransition:true to transOpts. This may be useful when you want to preload external views before the user starts using them.

var vc = ViewController.getInstance();
vc.openExternalView({
    url: "view1.html", 
    noTransition: true
}, win.body());

Example 4

To do something when the external view is ready:

var vc = ViewController.getInstance();
Deferred.when(vc.openExternalView({...}, win.body()), function(){
    doSomething();
});

Events

onStartTransition(evt)

A handler that performs view transition.

Parameter Type Description
evt undefined

Examples

Example 1

This example loads view1.html, creates a new view under <body>, and performs a transition to the new view with the slide animation.

var vc = ViewController.getInstance();
vc.openExternalView({
    url: "view1.html", 
    transition: "slide"
}, win.body());

Example 2

If you want to perform a view transition without animation, you can give transition:"none" to transOpts.

var vc = ViewController.getInstance();
vc.openExternalView({
    url: "view1.html", 
    transition: "none"
}, win.body());

Example 3

If you want to dynamically create an external view, but do not want to perform a view transition to it, you can give noTransition:true to transOpts. This may be useful when you want to preload external views before the user starts using them.

var vc = ViewController.getInstance();
vc.openExternalView({
    url: "view1.html", 
    noTransition: true
}, win.body());

Example 4

To do something when the external view is ready:

var vc = ViewController.getInstance();
Deferred.when(vc.openExternalView({...}, win.body()), function(){
    doSomething();
});
Error in the documentation? Can’t find what you are looking for? Let us know!