PDA

View Full Version : How referenced the iframe without to know your id



ec-cts
5 Feb 2008, 4:23 PM
I loaded any pages in center region through an iframe, according to the two post:

http://extjs.com/forum/showthread.php?t=24966
and
http://extjs.com/forum/showthread.php?p=54416#post54416

I have created a tab with a page inside, with this code:



Ext.ux.IFrameComponent = Ext.extend(Ext.BoxComponent, {
onRender : function(ct, position){
this.el = ct.createChild({tag: 'iframe', id: 'iframe-'+ this.id, frameBorder: 0, src: this.url});
}
});



Ext.getCmp('west-panel').body.on('click', function(e, target) {
e.stopEvent();
var center = Ext.getCmp('center-panel');
var newPanel = new Ext.Panel({
title: target.innerHTML,
loadScripts: true,
autoScroll: true,
closable: true,
layout:'fit',
items: [ new Ext.ux.IFrameComponent({ id: id, url: target.href }) ]
});
center.add(newPanel);
center.setActiveTab(newPanel);
}, this, {delegate: 'a.nav3'});


This method works fine (the open), but I need to close this tab from a button, and don't know how to refer this iframe in order to close the tab without to close the tab with 'x', and that is to be able to control that made any changes and is not saved.

With this way of creating the tab, I don't know what is the id, but if I know always the title tab.

Any ideas, please?

Thanks in advance.

Carlos Torres
Madrid-Spain
http://www.tsabogados.com my first ExtJs project