Skip to main content

Custom Events

Explore practical guides and implementation patterns for this topic.

Posts

Topic LWC
Lightning Web Components

Reusable Pagination Component in LWC: Client vs. Server-Side Guide

In plain words: A Reusable Pagination Component in Lightning Web Components (LWC) is a standalone UI control that breaks down massive data lists into numbered pages. It calculates total pages dynamically based on record count, highlights the active page button, and communicates page changes to parent components using a standard JavaScript CustomEvent . Displaying hundreds of records at once on a Salesforce dashboard or custom table creates visual clutter and degrades browser rendering speeds. Rather than duplicating navigation buttons and page calculations across multiple custom components, creating a modular child pagination component ensures clean separation of concerns. The child component manages navigation state, while the parent handles data slicing and server-side queries.
Read article
Topic LWC
Lightning Web Components

Mastering Salesforce LWC Custom Events: Complete Communication & Architecture Guide

In plain words: Custom Events allow child components in Salesforce Lightning Web Components (LWC) to talk back to their parent containers. When something happens in a child component (like clicking a button or submitting a form), it dispatches an event upward carrying data, letting the parent component react instantly without tight dependencies. Building complex applications in Salesforce Lightning Web Components (LWC) requires multiple components to work together seamlessly. Because components operate in isolated DOM trees, child components cannot directly modify parent data. Instead, Salesforce uses an event-driven architecture powered by Custom Events to establish clean, loosely coupled communication channels.
Read article
Topic LWC
Lightning Web Components

Mastering Communication in Salesforce Lightning Web Components (LWC)

In plain words: In Lightning Web Components (LWC), data flows down and events flow up . A parent passes data to a child through public @api properties, and can call a child's public @api methods. A child can't change the parent's data directly, so it sends a custom event with dispatchEvent , and the parent decides what to do with it. Real Salesforce apps are built from many small components that work together. To keep them clean and reusable, each component needs clear rules for how it talks to the others. This post covers both directions, parent to child and child to parent, using one simple example: a parent shows a product, and a child lets the user pick a quantity and add it to a cart.
Read article
Topic LWC
Lightning Web Components

Salesforce LWC Component Communication Masterclass: Parent, Child, LMS & External APIs

In plain words: Component communication in Salesforce Lightning Web Components (LWC) is how different parts of a screen share data and talk to each other. Depending on how components are related, developers use public properties ( @api ) to send data downward, custom events to notify parents upward, Lightning Message Service (LMS) for distant components, and Lightning Data Service (LDS) for automated database sync. Building rich, interactive user interfaces in Salesforce rarely involves a single standalone component. Most enterprise applications rely on modular architectures where multiple components collaborate to display and modify data. Mastering the various communication channels available in LWC ensures your applications remain performant, modular, and maintainable.
Read article
Topic LWC
Lightning Web Components

Building a Reusable Paginator in Salesforce LWC: Complete Component Guide

In plain words: A Paginator Component in Lightning Web Components (LWC) is a modular navigation control that splits large lists of records into manageable pages. It provides intuitive navigation buttons (First, Previous, Next, Last) and informs the parent component of page selections via standard JavaScript CustomEvent dispatches. Displaying hundreds of records at once on a Salesforce page slows down browser performance and overwhelms users. A dedicated child paginator component cleanly separates the user interface navigation controls from data retrieval logic, allowing you to reuse the exact same pagination toolbar across lists, data tables, and custom cards.
Read article
Topic LWC
Lightning Web Components

LWC Event Communication Examples: Parent-Child, Bubbling & Propagation

In plain words: In Lightning Web Components (LWC) , components communicate upwards by creating and dispatching a CustomEvent . A child component fires the event with a data payload, and an ancestor component catches it using an on{eventname} declarative listener or a programmatic DOM listener. Building maintainable Salesforce applications requires clean component communication. LWC adheres to standard DOM events following the principle of "properties down, events up." Below are three complete code patterns demonstrating direct child-to-parent messaging, cross-boundary event bubbling, and stopping event propagation.
Read article