Issue #3019💬 AnsweredOpened September 11, 2020by sircoko0 reactions

Bind inner text/html (like div, p, h1) to Trait

Quick answerby artf

changes in the canvas What kind of changes? How would you like to change the tag of the element in the canvas?

Read full answer below ↓

Question

Hi! I've created a custom trait, and I want to be allowed to change the content of the tags (in this case it's a H1 tag) based on the trait values..

It would be awesome if it can be bi-directional; changes in the traits panel will update the canvas and also changes in the canvas would update the input in the panel.

I've tried a lot of approaches with no success at all.

Do you have any clue?

Answers (3)

artfSeptember 14, 2020

changes in the canvas

What kind of changes? How would you like to change the tag of the element in the canvas?

sircokoSeptember 14, 2020

No, i want to change the content.

for example

<p> $CHANGE_THIS </p>

artfSeptember 14, 2020

onUpdate function in the custom trait definition allows you to update the input as you wish (in the example you see how the component parameter is passed and used to update the trait value)

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.