I am updating trait using addTrait function? It updates and adds the trait in trait manager but unable to reflect it in html section of codeManager?
Traits change the component (and its final HTML) when you use them. By simply updating traits collection in the component doesn't make any change to it on the HTML side
Read full answer below ↓Question
I have written the following code -
const component = editor.getSelected(); component.addTrait({ name: 'traitName', type: 'text', label: 'traitLabel', value: 'traitValue' }); const traits = component.get('traits'); traits.forEach(trait => console.log(trait.props()))
Answers (1)
Traits change the component (and its final HTML) when you use them. By simply updating traits collection in the component doesn't make any change to it on the HTML side
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3237
Add Trait For wrapper
Hi @artf I've added trait for wrapper this way. How can I perform the init function for the same Here is the code @artf Could you please he...
Issue #2333
can't able to remove the added traits properties[QUESTION]
Hi, I can able to add the traits properties dynamically by using the following code. but the following code to remove the type name is not...
Issue #4803
Traits value type select doesn't fill value
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 108 Reproducible demo link https://...
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.
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 →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.