You need to sign in to do that
Don't have an account?
Richard Cook
Lightning component works in standalone app but not when embedded in Visualforce page
I have a lightning component I've simplified down to having one ui:inputNumber. This is working when I surround it with a standalone Lightning app but it is giving errors when I embed it in a VisualForce page. The error I get displayed on my page is
Component:
afterRender threw an error in 'markup://ui:inputNumber' : this.ld.zeroDigit is undefinedI'm on Winter '16 and am following the standard example to embed a Lightning app & component in a VisualForce page.
Component:
<aura:component implements="flexipage:availableForAllPageTypes" controller="Pcmp_DiscountCalculatorController"> <aura:attribute name="derivedPrice" type="double" default="1000.00"/> <div> <div > Derived Price: <ui:inputNumber value="{!v.derivedPrice}" /> </div> </div>VisualForce Page:
<apex:page showHeader="false" standardStylesheets="false" sidebar="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0"> <!-- Script needed to embed Lightning Components in Visualforce pages. --> <apex:includeScript value="/lightning/lightning.out.js" /> <!-- Lightning Desktop extra styles and loading of Lightning Component--> <script type="text/javascript"> $Lightning.use("c:DiscountCalcVF", function() { $Lightning.createComponent("c:DiscountCalculatorPad", { accountId: "{!$CurrentPage.parameters.accountId}" , opportunityProductId : "{!$CurrentPage.parameters.productId}" }, "pricingpage", function(cmp) { // do some stuff }); }); </script> <html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <head> <title>Change this title</title> <apex:stylesheet value="{!URLFOR($Resource.SLDS0101, 'assets/styles/salesforce-lightning-design-system-vf.css')}" /> </head> <body> <!-- REQUIRED SLDS WRAPPER --> <div class="slds"> <!-- PRIMARY CONTENT WRAPPER --> <div class="myapp"> <div > <div id="pricingpage"></div> </div> <!-- / PRIMARY CONTENT WRAPPER --> </div> </div> <!-- / REQUIRED SLDS WRAPPER --> </body> </html> </apex:page>
Also, the way that aura:components work with Visualforce is with dependencies. Make sure you define your component in your application as an aura:dependency. For more info on that, see my post here: https://developer.salesforce.com/forums/ForumsMain?id=906F00000005I8mIAE
I'm not handling rendering at all, my component has just a simple ui:inputNumber in it.
I've pared my example down to a bare minimum, this component has a single ui:inputNumber in it, no controllers etc. You can load this in an org to see it for yourself.
If you comment out the ui:inputNumber and uncomment the ui:outputNumber then it doesn't display at all, instead showing
Uncaught error in $A.run() : Cannot read property 'charCodeAt' of undefined
Visualforce page, SimpleTestPage.page:
Lightning app, SimpleTestApp.app:
Lightning component, SimpleTestCmp.cmp:
If neither of those work, then you could always define an aura:attribute, and pass the locale in from your VF page.
Taken from here: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/expr_locale_value_provider.htm?search_text=$locale