Показать данные Json в Dojo - PullRequest
1 голос
/ 13 декабря 2011

Я создаю мобильное приложение Dojo. У меня есть файл Json, например:

{
    "Introduction": [
        {
            "title": "Introduction",
            "toolbar": "Page 1",
            "cont, aabitant morbi tristique senectus et netus et malesuada fames ac turpis nt pellentesque vehicula. Nam ac diam lectus. Aliquam convallis posuere enim.",
        },
        {
            "title": "Introduction",
            "toolbar": "Page 2",
            "contesent vel nisi ipsum. Suspendisse potenti. Pellentesque ut ipsum sit amet eros posuere venenatvis egestas. Sed congue felis at risus congue m",
        }
    ],
    "services": [
        {
            "title": "services",
            "toolbar": "Page 1",
            "content": "Cras adipiscing sapien nec tortor vehicula sit amet vehicula est fring.
        }
    ],
}

Сначала мне нужно прочитать этот файл. Будет задействовано 3 страницы. На первой странице будут показаны 2 пункта списка «Введение» и «Услуги». При нажатии на элемент списка «Введение» открывается его страница 1. На странице 1 будет кнопка. При нажатии на эту кнопку откроется страница 2.

То же самое будет в случае с "услугами". Я пытаюсь с dojo.xhrGet({ и ItemFileReadStore, но тщетно.

1 Ответ

5 голосов
/ 13 декабря 2011

Ваш JSON недействителен, вам не хватает «содержимого» в обоих объектах «Введение» (см. рабочий пример в jsFiddle ):

{
    Introduction: 
    [
        {
            title:   "Introduction",
            toolbar: "Page 1",
            content: "cont, aabitant morbi tristique..."
        },
        {
            title:   "Introduction",
            toolbar: "Page 2",
            content: "contesent vel nisi ipsum..."
        }
    ],
    Services: 
    [
        {
            title:   "services",
            toolbar: "Page 1",
            content: "Cras adipiscing sapien nec..."
        }
    ]
};
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...