dojox/mobile/dh/JsonContentHandler (version 1.10)

Summary

A JSON content handler.

This module is a content handler that creates a view from JSON data. If widgets used in the JSON data are not available, they are loaded automatically before instantiation.

There are two formats as shown in the examples below. You can choose either of them. The v1.7 format can be more compact, but if you want multiple widgets at the same level, they must be in an array. So, you can have, for example, two consecutive RoundRectLists, but you cannot have, for example, RoundRectCategory, RoundRectList, RoundRectCategory, and RoundRectList, because they are keys in one JS object, which causes conflict. The v1.8 format has no such limitation.

Examples

Example 1

// v1.7 format
{
  "dojox.mobile.View": {
    "@id": "view1",
    "dojox.mobile.Heading": {
      "@back": "Home",
      "@moveTo": "home",
      "@label": "view1.json"
    },
    "dojox.mobile.EdgeToEdgeList": {
      "dojox.mobile.ListItem": [{
        "@label": "Jack Coleman"
      }, {
        "@label": "James Evans"
      }, {
        "@label": "Jason Griffin"
      }]
    }
  }
}

Example 2

// v1.8 format
{
  "class": "dojox.mobile.View",
  "@id": "view1",
  "children": [

    {
      "class": "dojox.mobile.Heading",
      "@back": "Home",
      "@moveTo": "home",
      "@label": "view1.json"
    },

    {
      "class": "dojox.mobile.EdgeToEdgeList",
      "children": [
        {
          "class": "dojox.mobile.ListItem",
          "@label": "Jack Coleman"
        },
        {
          "class": "dojox.mobile.ListItem",
          "@label": "James Evans"
        },
        {
          "class": "dojox.mobile.ListItem",
          "@label": "Jason Griffin"
        }
      ]
    }

  ]
}

Example 3

// SpinWheel in v1.8 format
{
  "class": "dojox.mobile.View",
  "@id": "view1",
  "children": [
    {
      "class": "dojox.mobile.SpinWheel",
      "@id": "spin1",
      "@style": {"margin":"10px auto","width":"304px"},
      "children": [
        {
          "class": "dojox.mobile.SpinWheelSlot",
          "@labels": "A,B,C,D,E",
          "@style": {"textAlign":"center","width":"300px"}
        }
      ]
    }
  ]
}

Method Summary

  • _collectRequires(obj)
  • _instantiate(obj,node,parent) Given the evaluated json data, does the same thing as what the parser does.
  • _loadPrereqs(root)
  • parse(content,target,refNode) Parses the given data and creates a new view at the given position.

Methods

_collectRequires(obj)
Parameter Type Description
obj undefined
Returns:undefined
_instantiate(obj,node,parent)

Given the evaluated json data, does the same thing as what the parser does.

Parameter Type Description
obj Object
node DomNode
parent Widget
Returns:undefined
_loadPrereqs(root)
Parameter Type Description
root undefined
Returns:boolean | instance
parse(content,target,refNode)

Parses the given data and creates a new view at the given position.

Parameter Type Description
content Object

Content data for a new view.

target DomNode

A DOM node under which a new view is created.

refNode DomNode
Optional

An optional reference DOM node before which a new view is created.

Returns:undefined
Error in the documentation? Can’t find what you are looking for? Let us know!