1

我需要创建一个简单的个人资料页面。每当用户成功登录时,他将被重定向到个人资料页面,其中将显示他/她的信息和照片。我在下面尝试

Ext.define('casta.view.Intro', {
  extend: 'Ext.tab.Panel',
  xtype:'intro',
  //need to call url and render json data to the template below     
  config: {
        tpl: [
                '<tpl for=".">',
                    '<div class="holder">',
                            '<div class="avatar"><img src="{profile_image_url}" /></div>',
                            '<div class="h-content">',
                                '<h2>{user}</h2>',
                                '<p>{text}</p>',
                            '</div>',
                    '</div>',
                '</tpl>'
            ]  
  }
});

json数据如下

{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 2}, "objects": [{"date_joined": "2012-05-18T15:44:54", "first_name": "", "id": 1, "last_login": "2012-05-18T15:44:54", "last_name": "", "resource_uri": "/api/casta/user/1/", "username": "admin"}, {"date_joined": "2012-05-21T12:05:00", "first_name": "", "id": 29, "last_login": "2012-05-21T12:05:00", "last_name": "", "resource_uri": "/api/casta/user/29/", "username": "sumit"}]}

我需要调用 URL 来返回 json 并将其呈现在模板上。

帮帮我 :)

4

1 回答 1

0

尝试这样的事情

http://www.sencha.com/forum/archive/index.php/t-117847.html

Ext.setup({
onReady: function() {
var itemInfo = new Ext.XTemplate(
'<ul>',
'<tpl for=".">',
'<li>{name}</li>',
'</tpl>',
'</ul>'
);
var content = new Ext.Panel({
fullscreen: true,
scroll: 'vertical',
tpl: itemInfo
});


Ext.util.JSONP.request({
url: 'http://demo.webfactory.mk/',
callbackKey: 'callback',
params: {

action: 'retrieve'
},
callback: function(data) {

data = data.result;
content.update(data);

}
});
}
});
于 2012-05-24T09:37:17.467 回答