Issue #897πŸ’¬ AnsweredOpened February 24, 2018by konstantin550001 reactions

How to: find some component at canvas, on event "component:add"

Quick answerby konstantin55000❀ 1

Thanks for your attention. I just read the doc. And ended up with this solution: editor.on('component:add', function(currentComp) { if (currentComp.attributes.tagName == "form"){ var modelList = (domComps.getComponents()).models; var presentForms = modelList.filter(function(component) { return component.attributes.tag...

Read full answer below ↓

Question

Hi everyone, let say i've added block <form> on canvas. When i adding next <form> (second time) , need to check: if weather this component already present on canvas, call function implodeComponents(presentedComp, recentlyAddedComp){}

But, On event editor.on('component:add'... i can work only with recently added component. The question is : how to traverse through all components on canvas, to find special component (example <form>) Please look at http://prntscr.com/ij8c82 Thank you , for help.

Answers (3)

konstantin55000β€’ February 24, 2018

Thanks for your attention. I just read the doc. And ended up with this solution: editor.on('component:add', function(currentComp) { if (currentComp.attributes.tagName == "form"){ var modelList = (domComps.getComponents()).models; var presentForms = modelList.filter(function(component) { return comp...

ionic666β€’ June 11, 2018

@konstantin55000 hi ,bro ,domComps.getComponents() is getting all models,i just want to get button.how can i do it?thanks

lock[bot]β€’ September 17, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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.