Skip to main content
Hello, there. I'm working on very first Lightning application, and I'm noticing some strange behavior. I'm using a VF page with <apex:includeLightning /> and a script to load a component from an app like so:

 

$Lightning.use("c:OpportunityProductApp", function() {

$Lightning.createComponent("c:PricebookSelector", {}, "pricebookSelector", function(cmp) {

console.log('loaded component ...');

// do some stuff here

});

});

The Lightning application is very simple:

 

<aura:application access="GLOBAL" extends="ltng:outApp">

<c:PricebookSelector />

</aura:application>

The lightning component is as equally simple:

<aura:component controller="PricebookSelectorController">

<aura:attribute name="pricebooks" type="List" />

<aura:handler name="init" value="{!this}" action="{!c.doInit}" />

</aura:component>

The component controller looks like this:

({

doInit : function(component, event, helper) {

helper.getPricebooks(component);

}

})

Finally, the component helper looks like this:

({

getPricebooks: function(component) {

var action = component.get("c.getPricebooks");

var self = this;

action.setCallback(this, function(actionResult) {

console.log(actionResult);

});

$A.enqueueAction(action);

}

})

The problem:

When I load up the VF page, I get a debug to the console that the component has finished loading (as expected). However, I get two separate, but identical, log messages with the action result. Why are two calls made to the server??

Thanks so much. =)

 
4 answers
  1. Mar 7, 2016, 8:23 PM
    Not sure if this will make a difference, but in your aura:application, try replacing:

     

    <c:PricebookSelector />

    with:

     

    <aura:dependency resource="c:PricebookSelector"/>

     
0/9000