基本上我正在寻找这个问题,我有许多组件与服务器端用PHP写在服务器端。在Ext Js视口中动态地加载内容(面板)
根据用户的不同,我的组件将根据用户的角色进行更改。
所以我需要知道如何做到这一点的任何方式/示例/信息。
1-我使用了加载函数EXTJS,但它清楚地表明我不会加载脚本只是纯文本。
2-我使用的eval(),但即时有点害怕O此方法中,像该例子中箱布局组件(静态)
var contentPanel = new Ext.Panel({
frame: true,
style: {marginTop: '10px'},
height: 315,
border: true,
bodyBorder: false,
layout: 'fit',
id: 'contentPanel'
});
var mainPanel = new Ext.Panel({
title: 'Panel Principal',
id: 'mainPanel',
border: true,
frame: true,
width: '50%',
style: {margin: '50px auto 0 auto'},
height: 400,
renderTo: Ext.getBody(),
items: [
{
html: '<a href="#" onClick="requestContent(\'panel1\');">Panel 1</a>'
},
{
html: '<a href="#" onClick="requestContent(\'panel2\');">Panel 2</a>'
},
contentPanel
]
})
和更新与写在服务器上JS文件布局的内容
function receiveContent(options, success, response)
{
var respuesta = response.responseText;
//console.log(respuesta);
eval(respuesta);
//console.log(options.url);
url = options.url;
url = url.substring(0,(url.search(/(\.)/)));
var contenedor = Ext.getCmp('contentPanel');
contenedor.removeAll();
var contenido = Ext.getCmp(url);
contenedor.add(contenido);
contenedor.doLayout();
}
function requestContent(panel)
{
//panel es el nombre del archivo que quiero
Ext.Ajax.request({
url: panel+'.js',
callback: receiveContent
});
}
任何其他方式为此做什么我不想做的就是让一百万个不同的组件,并在登录时,许多人一样加载它们都似乎说
抱歉 - 不知道为什么代码标记不能用于我的文章,这意味着代码的格式不能正确显示...... – SW4 2010-09-16 10:15:45