• Shivam Lalwani
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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. =)