Skip to content

Instantly share code, notes, and snippets.

@salesforce-casts
Last active October 11, 2020 05:23
Show Gist options
  • Save salesforce-casts/d984f2bf7f72614b69950fcf317a0cee to your computer and use it in GitHub Desktop.
Save salesforce-casts/d984f2bf7f72614b69950fcf317a0cee to your computer and use it in GitHub Desktop.
Basic event handling. Not going to bubble though there are event listeners wrapping the button. {bubbles: false, composed : false} [Default config]
<template>
<c-child></c-child>
</template>
import { LightningElement, track } from 'lwc';
export default class App extends LightningElement {
}
<template>
<section onteja={handleTeja}>
<div onteja={handleTeja}>
<span onteja={handleTeja}>
<lightning-button label="Send" onclick={handleSend}>
</lightning-button>
</span>
</div>
</section>
</template>
import { LightningElement, api } from 'lwc';
/**
* Show an item
*/
export default class Child extends LightningElement {
handleSend(){
this.template.querySelector('span')
.dispatchEvent(new CustomEvent('teja'))
}
handleTeja(){
console.log('AM IN TEJA!!!!!');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment