Issue #2819💬 AnsweredOpened June 10, 2020by akashdesale980 reactions

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?

Quick answerby artf

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)

artfJune 17, 2020

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.

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 →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.