I want to add a javascript to the page dynamically after Ext.on.Ready() in Extjs4. In other words something similar to jQuery's getScript.
The private Ext.Loader.injectScriptElement/loadScriptFile method can be used to load an external JS file.
refer docs
check this
I would probably naively suggest just inserting a script tag into the page (because that's what I would do)
var script = document.createElement( "script" );
script.async = 'async'; //if you like
script.src = 'some/url/here';
var head = document.getElementsByTagName('head').item();
head.appendChild(script)
At least, that would work for now.
That's as opposed to doing something like this:
Ext.DomHelper.append(document.body, "<script type=\"text/javascript\" src=\"myScript.js\"></script>");
Naturally, I intend that you would put this code inside your onReady event handler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With