PDA

View Full Version : Why the Ext.onReady code can't execute in the dynamic code?



JetMah
27 Mar 2010, 7:54 PM
Here is the code:

main page:


Ext.get(target).load({
url:'/dynamic.html',
callback: function (el, success, response){
if (success) {
alert("Dynamic loading completed");
} else {
alert("Failed to load Page.");
}
},
scripts:true
});


dynamic.html:


<script type="text/javascript" src="scripts/dynamic.js?ver=20100318" charset="utf-8"></script>
<script type="text/javascript">Ext.onReady(App.pages.dynamic);</script>


and the dynamic.js:


Ext.ns('App.pages');

App.pages.dynamic = function() {
//...
};


If I do this, it can't find the App.pages.dynamic function. But it's ok if I put the Ext.onReady code in the dynamic.js, just like this:


Ext.ns('App.pages');

App.pages.dynamic = function() {
//...
};
Ext.onReady(App.pages.dynamic);


But why?

Thanks a lot!