2

伙计们。我已经开始使用 Sencha Touch,并且在我第一次尝试创建读取 JSON 文件然后将内容放入轮播单元格(有 6 个)的简单应用程序时遇到了困难。

这是到目前为止的代码:

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'
        }]
    });
}

});

这是json文件:

{
"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": "Запознай се с малките"
    }
]

}

所以基本上我想加载那个文件,解析它并将它放在第一个轮播“单元格”中(然后填充其他“单元格”)。我查看了文档,但我不知道该怎么做。任何帮助将不胜感激。

提前致谢。

4

2 回答 2

0

你看过这个例子吗?http://www.netmagazine.com/tutorials/build-ipad-app-sencha-touch

构建应用程序的非常深入的教程,从另一个来源(我认为是 Youtube,不记得了)提取数据并填充了大约 48 个具有可点击覆盖的缩略图 - 非常酷。

于 2011-08-22T07:39:16.497 回答
0

如果您在同一个域中,则无需使用 JSONP 加载。只需使用 Ext.Ajax.request。有一个从xml加载轮播内容的例子,思路是一样的。

于 2011-02-12T09:25:56.007 回答