Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

injecting a JavaScript after Ext.OnReady () event

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.

like image 379
pahan Avatar asked Feb 23 '26 22:02

pahan


2 Answers

The private Ext.Loader.injectScriptElement/loadScriptFile method can be used to load an external JS file.

refer docs

check this

like image 145
MMT Avatar answered Feb 25 '26 12:02

MMT


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.

like image 45
jcolebrand Avatar answered Feb 25 '26 12:02

jcolebrand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!