2011-02-09 3 views
2

남자. 나는 Sencha Touch로 게임을 시작했으며, JSON 파일을 읽고 간단한 컨텐트를 회전식 셀 (6 개)에 담는 간단한 앱을 만드는 첫 시도에서 벽을 쳤다. 여기 외부 JSON에서 데이터를 캐 러셀에로드하는 방법

지금까지 코드 :

Ext.setup({ 
icon: 'icon.png', 
glossOnIcon: false, 
phoneStartupScreen: 'phone_startup.png', 
onReady: function() { 

    var arena_zapad = new Ext.Component({ 
    title: 'Arena Zapad', 
    scroll: 'vertical', 
    tpl: [ 
     '<tpl for=".">', 
     '<div class="movie">', 
      '<div class="title"><h2>{title}</h2></div>', 
      '<div class="days">{days}</div>', 
     '</div>', 
     '</tpl>'   
     ]  
    }); 

    var refresh = function() { 
    Ext.util.JSONP.request({ 
     url: 'arena_zapad.json', 
     callbackKey: 'callback', 
     callback: function(data) { 
     arena_zapad.update(data)   
     } 
    }) 
    } 

    new Ext.TabPanel({ 
     fullscreen: true, 
     tabBar: { 
      dock: 'bottom', 
      layout: {pack: 'center'} 
     }, 
     animation: 'slide', 
     items: [{ 
      title: 'Movie Theaters', 
      iconCls: 'monitor2', 
      xtype: 'carousel', 
      items: [ 
       { html: "Arena Mladost", 
       cls: 'card card2' 
       // I want the json data here instead of html text 
       },{ 
       html: 'Arena West', 
       cls: 'card card2' 
      },{ 
       html: 'Арена The Mall', 
       cls: 'card card3' 
      },{ 
       html: 'Cineplex', 
       cls: 'card card3' 
      },{ 
       html: 'Cinema City', 
       cls: 'card card3' 
      },{ 
       html: 'M-TEL IMAX', 
       cls: 'card card3' 
      }] 
     }, { 
      title: 'Movies', 
      html: 'Movies', 
      iconCls: 'video_black2', 
      cls: 'card card1' 
     }, { 
      title: 'Premier', 
      html: 'Premier', 
      iconCls: 'photo3', 
      cls: 'card card3' 
     }, { 
      title: 'Favourites', 
      html: 'Favourites', 
      iconCls: 'favorites', 
      cls: 'card card1' 
     }, { 
      title: 'About', 
      html: 'About', 
      iconCls: 'info2', 
      cls: 'card card5' 
     }] 
    }); 
} 

}); 그러니까 기본적으로 내가 그 파일을로드를 분석하고 최초의 회전 목마 "세포"에 넣어 원하는

{ 
"movies": [ 
    { 
     "days": "Digital: 12:15, 14:15, 16:15, 18:15, 20:15, 22:15 35MM: 11:15, 13:15, 15:15, 17:15, 19:15, 21:15, 23:15", 
     "title": "TILT" 
    }, 
    { 
     "days": "9 февруари (сряда), 13:10, 15:30, 17:50, 19:00, 20:10, 21:20, 22:30", 
     "title": "Бурлеска" 
    }, 
    { 
     "days": "9 февруари (сряда), 12:00, 16:15", 
     "title": "Запознай се с малките" 
    } 
] 

}

(나중에 채울 : 여기

그리고

는 JSON 파일입니다 다른 "셀"). 설명서를 살펴 봤지만 어떻게할지는 모르겠습니다. 어떤 도움을 주시면 감사하겠습니다.

미리 감사드립니다.

답변

0

동일한 도메인에있는 경우 JSONP를 사용하여로드 할 필요가 없습니다. Ext.Ajax.request를 사용하십시오. xml에서 캐 러셀 컨텐츠를로드하는 예가 있습니다. 아이디어는 동일합니다.

+0

예제를 가르쳐 주시겠습니까? 나는 어디에서나 그것을 발견 할 수 없다. –