dalsbury
9 Apr 2007, 7:28 AM
I posted this question in reply to a post response (http://extjs.com/forum/showthread.php?t=4020)
When I use the same basic structure as Joe did in his example I find that I end up with an error, though my code still accomplishes the desired results minus the error message. The error that I receive is "Ext is not defined" because the Javascript is for some reason executed twice. The first time "Ext" is not defined, and the second time "Ext" is defined.
This is the code that loads the child module:
Ext.get("mainPanel").load({
url: panelURL + panelURLParameters,
scripts: true,
text: "Loading ..."
});
If the scripts is set to false, the page still executes once, but "Ext" is still not defined. On the second pass with scripts set to true, "Ext" is defined.
The workaround that I found though it seems a kludge is the following:
<script language="JavaScript" type="text/javascript">
var myForm = function(){
var simple = new Ext.Form({
labelWidth: 75, // label settings here cascade unless overridden
url:'save-form.php'
});
simple.add(
new Ext.form.TextField({
fieldLabel: 'Email',
name: 'email',
vtype:'email',
width:175
})
);
simple.render('form-ct');
};
// This is where I prevent the error by only executing on the second pass once Ext is defined
if (typeof(window['Ext']) !== "undefined")
{
Ext.onReady(myForm);
}
</script>
This seems to stop the errors, but I am wondering if there is a way to prevent the first execution of the code.
When I use the same basic structure as Joe did in his example I find that I end up with an error, though my code still accomplishes the desired results minus the error message. The error that I receive is "Ext is not defined" because the Javascript is for some reason executed twice. The first time "Ext" is not defined, and the second time "Ext" is defined.
This is the code that loads the child module:
Ext.get("mainPanel").load({
url: panelURL + panelURLParameters,
scripts: true,
text: "Loading ..."
});
If the scripts is set to false, the page still executes once, but "Ext" is still not defined. On the second pass with scripts set to true, "Ext" is defined.
The workaround that I found though it seems a kludge is the following:
<script language="JavaScript" type="text/javascript">
var myForm = function(){
var simple = new Ext.Form({
labelWidth: 75, // label settings here cascade unless overridden
url:'save-form.php'
});
simple.add(
new Ext.form.TextField({
fieldLabel: 'Email',
name: 'email',
vtype:'email',
width:175
})
);
simple.render('form-ct');
};
// This is where I prevent the error by only executing on the second pass once Ext is defined
if (typeof(window['Ext']) !== "undefined")
{
Ext.onReady(myForm);
}
</script>
This seems to stop the errors, but I am wondering if there is a way to prevent the first execution of the code.