2

I have a lightning component embeded into a Visualforce page.

VF page:

<apex:page>
    <apex:includeLightning />

    <div id="lightningComponent" />

    <script>
        $Lightning.use("c:SetupContainerApp", function() {
            $Lightning.createComponent(
                "c:SetupContainer",
                {},
                "lightningComponent",
                function(component) {
                }
            );
        });
    </script>
</apex:page>

Lightning App:

<aura:application description="SetupContainer" access="GLOBAL" extends="ltng:outApp">
    <aura:dependency resource="c:SetupContainer" />
    <aura:dependency resource="markup://force:*" type="EVENT"/>
</aura:application>

Lightning Component:

<aura:component description="SetupContainer" controller="SetupContactPointController"
                implements="force:appHostable">
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
</aura:component>

JS Controller:

({
    init: function(component, event, helper) {
        var action = component.get("c.getAllFields");
        action.setCallback(this, function(response) {
            var str = response.getReturnValue();
        });
        $A.enqueueAction(action);
    }
})

Apex Controller:

public with sharing class SetupContactPointController {
    @AuraEnabled
    public static String getAllFields() {
        return '';
    }
}

When the component is loaded and action action="{!c.init}" called the VF page is refreshed. I found the issue happens on $A.enqueueAction(action); line.

If I run the same component as a separate tab (without VF page container) the code works fine and the refresh doesn't happen.

How to make it work in VF page?

7
  • Is this the complete VF page code? where have you added <apex:includeLightning/> to the visualforce page. its needed to load lightning out libraries
    – RedDevil
    Mar 12, 2018 at 17:53
  • @RedDevil, I've updated my question with a full VF page code. Mar 12, 2018 at 20:12
  • I tried your code and it doesnt refresh for me.
    – RedDevil
    Mar 13, 2018 at 5:05
  • @RedDevil, thank you. I will try to reproduce the issue inside of another salesforce dev instance and then update my findings here. Mar 13, 2018 at 5:09
  • 1
    If possible put like a video of issue. between there is no need to explicitly load dependencies for system events in your app
    – RedDevil
    Mar 13, 2018 at 5:10

1 Answer 1

0

Remove the force* dependency inclusion from the the app markup and try.

<aura:application description="SetupContainer" access="GLOBAL" extends="ltng:outApp">
    <aura:dependency resource="c:SetupContainer" />
    <aura:dependency resource="markup://force:*" type="EVENT"/> -- not needed
</aura:application>
1
  • @Mikhail - posted the answer
    – RedDevil
    Mar 14, 2018 at 2:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .