Combo
  • Combo.js
  • Guide
    • Concepts
      • Lifecycle Methods
  • APIs
    • Component
      • canMount
      • canUnmount
      • canUpdate
      • created
      • el
      • isMounted
      • mount
      • mounting
      • mounted
      • on
      • props
      • receiving
      • received
      • refresh
      • render
      • rendered
      • state
      • unmount
      • unmounting
      • unmounted
      • update
      • updated
      • updating
  • FAQs
    • Props
    • State
    • Events
    • Ajax
Powered by GitBook
On this page
  1. FAQs

Events

Where do I define JavaScript event listeners?

Inside the rendered() life cycle method.

const Example = new class extends Combo.Component {
    mounted() {
        this.addEventListener("click", () => {
            alert("You fired a click event.");
        });
    }
    render() {
        return `
            <div>Click me</div>
        `;
    }
}();

Example.mount(document.getElementById("root"));
<div id="root"></div>
PreviousStateNextAjax

Last updated 6 years ago