
$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:
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. =)({
getPricebooks: function(component) {
var action = component.get("c.getPricebooks");
var self = this;
action.setCallback(this, function(actionResult) {
console.log(actionResult);
});
$A.enqueueAction(action);
}
})

Not sure if this will make a difference, but in your aura:application, try replacing:
with:<c:PricebookSelector />
<aura:dependency resource="c:PricebookSelector"/>