Apr 15, 2013, 9:11 AM
[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:
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]