How to: find some component at canvas, on event "component:add"
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)
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...
@konstantin55000 hi ,bro ,domComps.getComponents() is getting all models,i just want to get button.how can i do it?thanks
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.
Issue #1864
[QUESTION] Best way to listen to changes on the final HTML?
Hi, I just had a quick question because I could not figure out how to do it or did not find an issue related to it. I am just trying to cal...
Issue #1727
[QUESTION] Event to get children view
I have a problem with a component. When I drop a component into the canvas I create a simple object. Before appending this object I need to...
Issue #1617
[Question] How can I stop the drop from block:drag:start event? Also is there any event to listen Invalid target position?
First of all, I really appreciate your replies on my questions. Thank you for all. Question 1 : I've a situation where if a particular bloc...
Issue #1982
[QUESTIONS] addcomponent after the selected component
how do I make it possible to add new components after the component I selected, at this time I use editor.DomComponents.addComponent (block...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins β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.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.