I am following this guide to communicate between my LWC and my aura component. But for some weird reason it still doesnt work.
myComponent.cmp
<aura:component implements="force:hasSObjectName,lightning:actionOverride" >
<ui:scrollerWrapper class="scrollerSize" aura:id="scrollerTop">
<!-- Other code -->
</ui:scrollerWrapper>
<!-- My test Lightning Web Component -->
<c:helloworld onfilterchange="{!c.handleEvent}"/>
</aura:component>
myComponentController.js
({
handleEvent: function(component, event, helper) {
console.log("BACK!");
}
});
helloworld.js
import { LightningElement } from 'lwc';
export default class HelloWorld extends LightningElement {
constructor(){
super()
window.addEventListener("message", this.fireEvent, false, {
once: true
});
}
fireEvent(event){
const filterChangeEvent = new CustomEvent('filterchange', {
detail: { "HELLO": 'TEST' }
});
try{
var data = JSON.parse(event.data);
if(data.ap_mobile){
// Fire the custom event
this.dispatchEvent(filterChangeEvent);
console.log("Event Fired!");
}
}catch(error){
console.log("Error Parsing");
}
}
}
The Event Fired!
text is shown but thats it, the controller doesnt fire the handleEvent
function at all.
What am I doing wrong?
<c:helloWorld />
doesnt exist