I have two tabs, based on the inserted record in first tab, I'm displaying data in the second tab from server. if I go back to first tab and update the inserted record and then click on second tab it is still displaying data based on my inserted records
I want my records in the second tab should be displayed based on the recently updated records.
to display records in the second tab I have created one separate component and on its "init" I'm doing server-side call. but it seems "init" is always called only on the first occurrence.
I also tried using aura:method, but it gives error "[childComponent.myMethod is not a function]"
Child Component:
<aura:method name="myMethod" action="{!c.executeMyMethod}">
<aura:attribute name="param1" type="Obj1[]"/>
<aura:attribute name="param2" type="Obj2"/>
</aura:method>
Child controller:
executeMyMethod : function (component, event, helper) {
console.log("Inside Execute method.. ");
var params = event.getParam('arguments');
console.log('Param 1: '+ params.param1);
console.log('Param 2: '+ params.param2);
},
Parent Component:
<lightning:tabset>
<aura:attribute name="cost" type="integer" default="1"/>
<aura:attribute name="insetedObj1" type="Obj1[]"/>
<aura:attribute name="recordObj2" type="Obj2"/>
<lightning:tab>
<ui:inputNumber value="{!v.cost}" />
<button class="slds-button" disabled="false"
onclick="{!c.getChild}">Save</button>
</lightning:tab>
<lightning:tab id="second">
<c:childComponent aura:id="child"/>
</lightning:tab>
</lightning:tabset>
Parent Controller:
getChild: function(component, event, helper){
var costvalue = component.get("v.cost");
var action = component.get("c.getChildRecord");
action.setParams({
"parameter":costvalue
});
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var result = response.getReturnValue();
component.set("v.insetedObj1",result);
var attribute1 = component.get('v.insetedObj1');
var attribute2 = component.get('v.recordObj2');
var childComponent = component.find('child');
childComponent.myMethod(attribute1, attribute2);
component.set("v.tabId",'second');
}
});
$A.enqueueAction(action);
}
aura:method
, what you say?