2011-12-13 2 views
1

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

{ 
    "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, но напрасно.

ответ

5

Ваш JSON не действует, вам не хватает "содержание" в обоих объектов "Введение" (см working example at 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..." 
     } 
    ] 
}; 
Смежные вопросы