0

For the DataTable, there is a row click select function and in one cell, there are action buttons.

Comp 1:

<aura:component >
    ..
    <tr class="{! 'file-list-row ' + (file.checked?'slds-is-selected':'')}" onclick="{!c.toggleRowSelect}" data-file-id="{!file.id}">

         <td>
               <c:Actions file="{!file}" objectName="cg__S3Object__c" ></c:Actions>
         </td>
    </tr>
    ..
</aura:component>

I want to stop propogation for action buttons on click. And according to documantation I have tried to:

Comp 2 (Actions):

<aura:component controller="FileListController">

..
<aura:registerEvent name="sampleComponentEvent" type="COMPONENT"/>
<aura:handler name="sampleComponentEvent" event="COMPONENT" action="{!c.handleSampleEvent}"/>

    ..
</aura:component>

and the controller should be:

handleBubbling: function(component, event, helper) {
        event.stopPropagation();
    }

Documentation: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_component_bubbling.htm

However I get this error message over and over again, no matter what I try:

enter image description here

1

Aura:registeretevent name = "samplecompnent" type ="c:eventname" you have not specified type in register event

| improve this answer | |
  • I have tried this also, type ="c:copmEvent" but error message is same... – efirat Jun 21 '17 at 11:02
  • I just want to prevent event propagation from component to container component... – efirat Jun 21 '17 at 11:02
  • 1
    Did you specified event ="c:eventname" in handler also – Manjot Singh Jun 21 '17 at 11:05
  • 1
    Can you post what is event name and event here – Manjot Singh Jun 21 '17 at 11:06
  • Yes, I have also used this eventname for handler... <aura:registerEvent name="sampleComponentEvent" type="c:compEvent"/> <aura:handler name="sampleComponentEvent" event="c:compEvent" action="{!c.handleSampleEvent}"/> – efirat Jun 21 '17 at 11:10
1

I know it is NOT regular way, but after two hour of time lose, it works...

<aura:component >
    <div onclick="{!c.mainDivClik}">

        ..

    </div>
</aura:component>

On the controller:

mainDivClik: function(component, event, helper) {
    event.stopPropagation();
}

Thats it.

| improve this answer | |
  • We use a similar approach in Salesforce1. Would like to see a native / aura way as well – Christian Szandor Knapp Jun 21 '17 at 12:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.