You need to sign in to do that
Don't have an account?
Sandeesh Phulkar 3
How to include external scripts in a Lightning Component/App
Hello,
I wish to include :-
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
extenal library for Google maps in a lightning component.
It doesnt allow me to do so , it gives me the following error:-
Content Security Policy: The page's settings blocked the loading of a resource at http://maps.google.com/maps/api/js?sensor=false ("script-src https://ap1.lightning.force.com https://ssl.gstatic.com chrome-extension: 'unsafe-eval' 'unsafe-inline'").
I tried loading this script asynchronously as well , by creating dynamic <script> tag and loading the src. Still doesnt work.
Kindly let me know how I can get Google Maps to work in a Lightning Component.
Thanks in advance
I wish to include :-
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
extenal library for Google maps in a lightning component.
It doesnt allow me to do so , it gives me the following error:-
Content Security Policy: The page's settings blocked the loading of a resource at http://maps.google.com/maps/api/js?sensor=false ("script-src https://ap1.lightning.force.com https://ssl.gstatic.com chrome-extension: 'unsafe-eval' 'unsafe-inline'").
I tried loading this script asynchronously as well , by creating dynamic <script> tag and loading the src. Still doesnt work.
Kindly let me know how I can get Google Maps to work in a Lightning Component.
Thanks in advance
http://enreeco.blogspot.it/2014/10/salesforce-lightning-loading-scripts.html
Use RequireJS to load whatever script you want.
Hope this helps
--
May the Force.com be with you!
Thanks for the update.
But unfortunately loading the script through RequireJS also doesnt help.
Gives the same error.
Thanks for the great article you wrote. Read your post and it was very helpful for me to get the Jquery working in Lightning app.
Actually you have to load any script from a local resource (static resource) and cannot load from outside.
This is a known limitation (and wanted).
For more details: http://www.salesforce.com/us/developer/docs/lightning/lightning.pdf (page 95 "Using JavaScript Libraries" that states "The framework’s content security policy mandates that external JavaScript libraries must be uploaded to Salesforce static resources. For
more information, see Content Security Policy Overview on page 90.")
I recall using things like jQuery from network URLs when prototyping and then pulling them down and storing them locally in static resources for production. I don't know if that would work with this library.
-Ken
It gives an error somehing like:- "document.weite failed on the file."
Thanks
this would be a really important feature for the framework!
Can't wait for it!
--
May the Force.com be with us :)
Did we get the solution for this issue now? OR anybody figured out any workaround to get Google Chart/Map working inside lightning?
Please be posted, I think the feature to include external scripts is going to be the key for the sucess of lightning platform.
https://developer.salesforce.com/blogs/developer-relations/2015/04/creating-salesforce-lightning-map-component.html
Never the less, we've got a start into loading maps inside a Salesforce Lightning Component.
Thanks Christophe Coenraets for your article at http://coenraets.org/blog/2015/04/creating-a-salesforce-lightning-map-component/#comment-1515482
https://success.salesforce.com/ideaView?id=0873A000000LlVWQA0
Go to Setup select Critical Update
Deactivate: Enable Lightning LockerService Security
and paste below code in developer console
1 Step: Insert into component
<ltng:require scripts="/resource/Jq" afterScriptsLoaded="{!c.afterScriptsLoaded}" />
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 Step: Insert into Component
<button id="button1" onclick="{!c.dropdown}" class="slds-button slds-button--neutral">Show/Hide Columns
<img src="/resource/dropdownIcon" style="height:20px; width:20px;"/></button>
<p id="dropdown1">hi</p>
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Step 3: insert into Controller
({
afterScriptsLoaded : function(component, event, helper) {
},
dropdown:function(component, event, helper)
{
// console.log("1st time");
// $.noConflict();
jQuery("#dropdown1").toggle();
//console.log("2nd time");
}
})