Issue #5280πŸ’¬ AnsweredOpened Aug 7, 2023by fluke7770 reactions

Event handler on view not bound to the component

Quick answerby artf

The error here is using the arrow function, just replace it with clickOnElement() {

Read full answer below ↓

Question

GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Version 115.0.5790.114 Reproducible demo link https://jsfiddle.net/mcraf3se/5/ Describe the bug Hello, just starting with GrapesJS so it is quite likely I am misunderstanding something fundamental. I am struggling with setting the event handlers on the view of a custom component. How to reproduce the bug? In the linked JS fiddle.Drag block My Div onto canvasClick inside it (there should be a div with 'stuff'). What is the expected behavior? Per documentation here the event handlers should b...

Answers (2)

artfβ€’ Aug 7, 2023

The error here is using the arrow function, just replace it with clickOnElement() {

GJS Helperβ€’ May 17, 2026

The issue you're encountering with this being window or undefined inside your custom component's view event handler is a common JavaScript this binding problem, especially when using arrow functions. It's not a bug in GrapesJS but rather a misunderstanding of how this works with arrow functions in...

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins β†’
Premium option

Premium plugins ship with support, regular updates, and production-ready features β€” save days of integration work.

Browse premium plugins β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.