When a component is clicked is there a hook to know when the traits have rendered.
Question
Hey Grapes Community, When a component is clicked from within canvas is there a hook or event to know when the traits have rendered in view container for the selected component?
Answers (2)
Perfect, Thank you!
Hi there!
When a component is clicked
component:selected is the event you are looking for. more on this here
to know when the traits have rendered in view container
based on the nature of the the suggested event, you will receive the model of the selected component as an argument, this way you can check for the availability of any trait on the model:
editor.on('component:selected', ( model => {
console.log(model.get('traits'))
})
)
cheers!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2418
Is there an api or function to insert a value in a data-attribute in the canvas?
Hey Grapes Community! I created a custom trait select field that fetches options from our db for <a> components... when <a>(link) is clicke...
Issue #2404
Question: how to observe children changes in component
Is there an easy way to subscribe/listen to changes in the components/children of my custom component type? Perhaps an event I can subscrib...
Issue #3461
Re-render trait on selected component
I know there is a function that can rerender the view of a trait. However, I still don't know how and where to use it.
Issue #2193
[QUESTION] Reset trait on edit the content of a custom component
Hi, I have a custom component which content can be changed by switching trait select options, but also can be edited similar to the text co...
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.
Tutorial
Building an AI-Assisted Document Engine with Next.js, GrapesJS, and the AI SDK
Transform your static template editor into an intelligent, generative design workspace with Vercel AI SDK, AI Elements and Next.js.
Tutorial
Ship to Production Faster: Whatβs New in GrapesJS Shadcn
Supercharge your page builder! GrapesJS Shadcn adds live drag previews, rich text / commands, dynamic data, and canvas presets to ship to prod faster.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.