PDA

View Full Version : how to load components dynamically in the parent frame



weige215
23 Apr 2010, 9:20 PM
i have a window in parent page , in iframe i have a component returned by ajax, but use window's add method load this component , it always prompt "this container is null", please help me!

the Source Code such as:

var AddPermissionWin = new parent.Ext.Window({
id: "AddPermissionWin",
title: "????",
width: 500,
autoHeight: true,
border: false,
modal: true,
resizable: false
});

Ext.Ajax.request({
url: '<?php echo url('permissions/LoadAddPermissionsDataPage');?>',
success: function(xhr) {
var newComponent = eval(xhr.responseText);
AddPermissionWin.add(newComponent);
AddPermissionWin.show();
}
});

newComponent var always prompt null, but newComponent has been returned! why AddPermissionWin.add method prompt "this container is null" error?

Gerrat
26 Apr 2010, 1:03 PM
Instead of:
var newComponent = eval(xhr.responseText);
try:
var newComponent = eval('(' + xhr.responseText + ')');

...but if this doesn't help, it's just a guessing game without knowing what "xhr.responseText" is.

CrazyEnigma
26 Apr 2010, 8:22 PM
Limit the use of eval, this poses security issues. Use this instead:


Ext.encode(xhr.responseText);


But this may be the least of your worries.