Issue #1813Opened February 19, 2019by ateebahmed0 reactions

[Question]: Can't get correct component from editor.on events callback

Question

I am using editor's events to get component after some action like component:add, block:drag:stop, but in both events I can't get my component that I dragged on canvas.

when I call component.is('my-component-type'), it gives false, I need to perform actions based on its type, which I can't when I get that from event's callback, but if I select a component and register listener on component:selected, I get the right type, how can I have this behaviour with other events?

Answers (3)

artfFebruary 22, 20190 reactions

You're doing something wrong, works as expected here https://jsfiddle.net/nfkha41p/

Next time, create a reproducible demo first, then open an issue...

ateebahmedFebruary 22, 20190 reactions

Actually I can't produce it with built-in components but I'm using a custom component which extends default text component, will paste the code as I could not find which property to set to get the component type, although I had set type: 'my-type' in BlocksManager.

naveen-15697November 11, 20190 reactions

You're doing something wrong, works as expected here https://jsfiddle.net/nfkha41p/

Next time, create a reproducible demo first, then open an issue...

@artf Here, when I drag a first component, I get three alerts. But I need only the parent component. i.e, the first alert. Is there any solution?

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.