javascript - how to use external js library with Aura? -


i've added

<script language="javascript" type="text/javascript" src="../js/chart.bundle.js"></script>   

in aura:application file, file downloaded browser (can see thru console) when try create chart object in afterrender function in renderer

var mychart = new chart(ctx, { ..... 

i've got error:

something has gone wrong. afterrender threw error in 'markup://helloworld:helloworld' [afterrender threw error in 'markup://c:ltgraph' [referenceerror: chart not defined]] failing descriptor: {markup://helloworld:helloworld} error @ new (http://localhost:8080/aurafw/javascript/lg7eyfz_mxfcccxumk95lq/aura_dev.js:3152:23) @ http://localhost:8080/aurafw/javascript/lg7eyfz_mxfcccxumk95lq/aura_dev.js:1:1. please try again.

how use external libraries in aura ?

i've found problem. code wanted use library before loaded. have put checks in js code (renderer)

var timestocheck = 10; var poll = function () {     settimeout(function () {         timestocheck--;         if (typeof chart !== 'undefined') {              // can use chart (or other) library.....          } else if (timestocheck > 0) {             poll();         } else {             console.log('giving up')         }     }, 100); }; poll(); 

(code taken https://developer.salesforce.com/forums/?id=906f0000000amaz )

but still, have problem loading 2 dependent libraries (like jquery , flot). quite there error jquery undefined during flot initialization.....


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -