2011-02-09 20 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

例を指摘できますか?どこにも見つけられない –

0

この例を見ましたか? http://www.netmagazine.com/tutorials/build-ipad-app-sencha-touch

別のソースからのアプリ引っ張るデータの構築に非常に綿密なチュートリアル(私はそれがYouTubeのだと思う、覚えていないことができます)と、クリック可能なオーバーレイを持っている約48サムネイル移入 - 非常にクールに。

si

関連する問題