Results 1 to 3 of 3

Thread: Get a reference to an object which is loaded to panel

  1. #1

    Question Get a reference to an object which is loaded to panel

    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

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258

    Default

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

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

  3. #3

    Default loading html to panel

    Thanks
    That helped a lot.
    Cheers


    Quote Originally Posted by evant View Post
    The loading is asynchronous. When you make your call for the button, the page probably hasn't loaded yet.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •