PDA

View Full Version : Get a reference to an object which is loaded to panel



captainsina
24 Apr 2008, 5:30 AM
Hi all,
I am using the load method to load a button tag into a panel. It shows everything properly. But I cannot get a reference to the element. Here is the code of the html page called Hello.html:

<inputtype="button"id="btn"name="btnName"value="Hello Worldddd"/>

Then in my js file i try to get this button:

Ext.onReady(function(){
var p = new Ext.Panel({
title: 'My Panel',
collapsible:true,
renderTo: 'script',
width:400
});

p.load('hello.html');
var myButton= Ext.get('btn');
});

myButton is always null!
Is there anyway to do this?
Thanks

evant
24 Apr 2008, 5:46 AM
The loading is asynchronous. When you make your call for the button, the page probably hasn't loaded yet.



p.load(
{
url: 'foo.html',
callback: function()
{
console.log(Ext.get('mydiv').id);
}
}
);

captainsina
24 Apr 2008, 6:22 AM
Thanks
That helped a lot.
Cheers



The loading is asynchronous. When you make your call for the button, the page probably hasn't loaded yet.



p.load(
{
url: 'foo.html',
callback: function()
{
console.log(Ext.get('mydiv').id);
}
}
);