I have yet another event-driven question. How can I send a refresh to a parent component via the child?


<aura:event type="COMPONENT" description="CDEContextTagEvent">
    <aura:attribute name="message" type="String" />

Parent CMP

<aura:handler name="lightningEvent" 
              action="{!c.handleComponentEvent}" />

<aura:attribute name="message" type="String"/>

<aura:iteration items="{!v.manageView}" var="row">
    <c:CDECContextTagRow view="{!row}"/>

Parent Controller

handleComponentEvent : function(cmp, event, helper){
    var message = event.getParam("message");
    var action = cmp.get("c.CDEContextTagListController");

        function(response) {
            var state = response.getState();
            if (state === 'SUCCESS'){
            } else {
                 //do something

Child CMP

<aura:registerEvent name="lightningEvent"
                    type="c:CDEContextTagEvent" />
        <td data-label="">
            <div class="slds-truncate" >
                <button onclick="{!c.callDeleteRecord}" 
                          title="Delete Record">
                    <lightning:icon iconName="action:delete" 
                    <span class="slds-assistive-text">Delete</span>

Child Controller

    callDeleteRecord : function(component, event, helper) {
        var action = component.get("c.deleteTagName");
        var currentRecordId = component.get("v.view.Id");
        action.setParams({"currentRecordId" : currentRecordId});

        var answer = confirm ("Are you sure you want to delete this tag?");
            var toastEvent = $A.get("e.force:showToast");
                "type": "Error",
                "title": "Deleted!",
                "message": "The deficiency tag has been deleted successfully."

            var event = component.getEvent("lightningEvent");
                "message" : "MESSAGE TEST" });
  • 1
    Where are you stuck? – Sebastian Kessel Apr 25 '18 at 3:26
  • This all looks correct and you are not using the message anywhere in the handleApplicationEvent method, and the event is the component type, not the application one, and you used method name handleApplicationEvent like you are handling an application type event. – itzmukeshy7 Apr 25 '18 at 6:16
  • Oops! Sorry about the naming! Fixed! I am stuck as to why the component isn't refreshing after calling delete. Confirmation alert pops up, toast message pops up, then silent... :( – Jeff Apr 25 '18 at 13:11
  • Where are the confirmation alert and the toast message fired? Do you know for sure that your server-side controller is returning successfully? – David Reed Apr 25 '18 at 13:15
  • @David Hey David, I edited it again to show where exactly it is trying to fire. Also, I'm not able to display the "message" from the parent controller which I'm assuming is due to the event not being fired properly? – Jeff Apr 25 '18 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.