You need to sign in to do that
Don't have an account?

Loading Javascript using <ltng : require>
Hi All,
I am new Salesforce Lightning experience. I am trying to call an external JavaScript by loading it as a Static resource and calling it in my Lightning application using the following syntax but I am unable to get it work.
<aura:application >
<ltng:require scripts="{!$Resource.SDFCTestJS}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
</aura:application>
Please suggest how can I get it work.
P.S : I read a solution that we can load Javascript by creating a Helper class and call it from our Component. Can anyone suggest a way so that I don't need to create helper everytime I call a component as I am going to have many; a way that I can include the JS directly from the above.
Thanks in advance.
Warm Regards,
Shubham
SFDC
I am new Salesforce Lightning experience. I am trying to call an external JavaScript by loading it as a Static resource and calling it in my Lightning application using the following syntax but I am unable to get it work.
<aura:application >
<ltng:require scripts="{!$Resource.SDFCTestJS}" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
</aura:application>
Please suggest how can I get it work.
P.S : I read a solution that we can load Javascript by creating a Helper class and call it from our Component. Can anyone suggest a way so that I don't need to create helper everytime I call a component as I am going to have many; a way that I can include the JS directly from the above.
Thanks in advance.
Warm Regards,
Shubham
SFDC
Try to use normal script tag instead of this. Thank You,
Hitesh Patel
Email :- hiteshpatel.aspl@gmail.com
http://mrjavascript.blogspot.in/
Shubham Sehgal
use this code your problem is solve out
<ltng:require scripts="/resource/jq/"/>
where jq is the name of static resource upload in org.
if this is help full please mark the best
Thanks & Regards
Jasveer Singh
Thank youo for your response.
I tried using your code. Still not working. No error this time but nothing appears on the page.
Please suggest.
Thanks
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000kFDHIA2
Thanks & Regards
Jasveer Singh
<ltng:require scripts="/resource/jq/" afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
</aura:application>