Results 1 to 3 of 3

Thread: Load external script within Ext JS 4

  1. #1
    Sencha User
    Join Date
    Jul 2014
    Posts
    17

    Default Load external script within Ext JS 4

    Within Ext JS 4, I need to load D3 API. I am using the below code

    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.

  2. #2
    Sencha - Sustaining Engineer tristan.lee's Avatar
    Join Date
    Mar 2015
    Location
    Central Ohio
    Posts
    1,579
    Answers
    165

    Default

    Hi,

    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?

    Thanks,
    Tristan

  3. #3
    Sencha User
    Join Date
    Jul 2014
    Posts
    17

    Default

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

Similar Threads

  1. Loading and External script into a panel
    By damiansmith in forum Sencha Architect 2.x: Help & Discussions
    Replies: 0
    Last Post: 20 Feb 2013, 9:04 PM
  2. Load external java script files for an "item"
    By preyz in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 19 Apr 2011, 2:21 AM
  3. Include external script with javascript
    By marleone in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 8 Sep 2008, 9:42 AM
  4. Replies: 6
    Last Post: 7 May 2008, 10:31 PM
  5. How to get external script with extjs
    By psscommusic in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 6 May 2008, 5:34 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •