Well, basically, I look at this problem, I have many components with dynamic material written on server side with PHP.
Depending on the user, my components will vary depending on the role of the user.
Therefore, I need to know any ways / examples / information on how to do this.
1- I used the EXTJS download function, but it clearly says that I am not loading the script just plain text.
2- I used eval (), but I was a little scared of this approach, for example, this cell layout component (static)
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
]
})
and update the contents of the layout using js files written on the server
function receiveContent(options, success, response)
{
var respuesta = response.responseText;
eval(respuesta);
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)
{
Ext.Ajax.request({
url: panel+'.js',
callback: receiveContent
});
}
, , , .