[CLOSED] Ext.onReady and Resource Manager DocumentReady

  1. #1

    [CLOSED] Ext.onReady and Resource Manager DocumentReady

    Hi,
    I'm a bit confused at the following after doing a little housekeeping and looking at which technique to use with Ext.onReady.

    If I declare inline Ext.onReady in the head of a page, I cannot access a control, whereas if I used the Resource Manager DocumentReady listener, it works fine. A little confusing seeing as they both do the same thing surely?

    Out of curiosity. If you cut and paste the inline script I've written below and put it after the closing HTML tag, it finds the control using both techniques. Confusing! An explanation would be very much appreciated. See code below:

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
        <script language="javascript" type="text/javascript">
            Ext.onReady(function () {
    
                var textbox = Ext.getCmp('txtSample');
                //control is undefined - uncomment below to show control is not found
                //console.log('Inline onready found: ' + textbox.id);
            });
    
            function ExtReady() {
    
                var textbox = Ext.getCmp('txtSample');
                console.log('Resource Manager onready call found: ' + textbox.id);
            }
        </script>
        
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server">
            <Listeners>
                <DocumentReady Handler="ExtReady()" />
            </Listeners>
        </ext:ResourceManager>
        <form id="form1" runat="server">
        <ext:TextField runat="server" ID="txtSample" ClientIDMode="Static" Text="Hello world" Width="300"></ext:TextField>
        </form>
    </body>
    </html>
    Last edited by Daniil; Apr 15, 2013 at 2:03 PM. Reason: [CLOSED]
  2. #2
    Hi @Kev,

    Yes, a DocumentReady listener produces an Ext.onReady handler, but put it after an Ext.NET initialization script.

    Actually, an Ext.NET initialization script is an Ext.onReady listener as well, which creates Ext.NET components which you defined in markup/code behind.

    So, you can get access to those components only after executing of an Ext.NET initialization script.

    If you explicitly put your custom Ext.onReady handler after an Ext.NET initialization script, it will behave the same way.

    Example
    <ext:ResourcePlaceHolder runat="server" Mode="Script" />
    
    <script>
        Ext.onReady(yourHandler);
    </script>
    You might need to investigate Page Sources to understand better what I am talking about.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @Kev,

    Yes, a DocumentReady listener produces an Ext.onReady handler, but put it after an Ext.NET initialization script.

    Actually, an Ext.NET initialization script is an Ext.onReady listener as well, which creates Ext.NET components which you defined in markup/code behind.

    So, you can get access to those components only after executing of an Ext.NET initialization script.

    If you explicitly put your custom Ext.onReady handler after an Ext.NET initialization script, it will behave the same way.

    Example
    <ext:ResourcePlaceHolder runat="server" Mode="Script" />
    
    <script>
        Ext.onReady(yourHandler);
    </script>
    You might need to investigate Page Sources to understand better what I am talking about.
    Thanks Daniil. Yes, I've examined the source code after what you suggested and can see what you mean. I can see that the init function, the creation of the controls and self executing function which contains my ExtReady function are now above my Ext.onReady declaration. Makes complete sense. Thank you for your explanation.
  4. #4
    Two years using Ext... and Finally knows the true about that.

    Thanks @Daniil and @Kev
  5. #5
    Hi @equiman,

    Nice that it helped you:)

Similar Threads

  1. [CLOSED] resource manager and limiting extjs file size
    By craig2005 in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Oct 03, 2013, 9:41 AM
  2. [CLOSED] What is the Resource Manager and how do I use it?
    By jwf in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 29, 2011, 6:46 PM
  3. Script Manager and Resource Manager Conflict
    By EugeneNiemand in forum 1.x Help
    Replies: 6
    Last Post: Jun 20, 2011, 7:34 AM
  4. Replies: 5
    Last Post: Oct 26, 2010, 2:20 PM
  5. Replies: 4
    Last Post: Sep 22, 2010, 7:43 AM

Tags for this Thread

Posting Permissions