View Full Version : Load external script within Ext JS 4

21 Apr 2015, 8:21 PM
Within Ext JS 4, I need to load D3 API. I am using the below code

loadScript: function(callback, scope) { console.log('5) loadScript called');
Ext.Loader.injectScriptElement('http://d3js.org/d3.v3.js', onLoad, onError);
console.log('D3 script loaded ');

onError : function() {
console.log('On Error');
onLoad : function() {
console.log('On Load');
d3.select('body').append('div').style('position', 'absolute').style('padding', '0 10px').style('background', 'red').style('opacity', 0);

However, in browser console, I get the below error -

Uncaught ReferenceError: onLoad is not defined

Can someone please help me rectify the above code?

Thank you.

22 Apr 2015, 5:36 AM

It's hard to tell from your code sample as it is incomplete and doesn't appear valid, but it appears you are trying to reference onLoad before it's defined just as the error message states. Can you post a workable example as a fiddle (https://fiddle.sencha.com) so I can work through this with you?


23 Apr 2015, 11:20 AM
Thank you. This solved the problemExt.Loader.injectScriptElement('http://d3js.org/d3.v3.js', this.onLoad, this.onError, this);