Issue #4774💬 AnsweredOpened December 9, 2022by edenizk1 reactions

Can't set traits in attributes

Quick answerby artf1

You should use properly parsable JSON strings eg, data-gjs-traits='["id"]', data-gjs-traits="[]"

Read full answer below ↓

Question

GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Firefox Reproducible demo link https://jsfiddle.net/9aj630x7/ Describe the bug How to reproduce the bug?Create a elementset data-gjs-traits attribute to any default trait name like id or title, it will crush the whole thing What is the expected behavior? I expect the same result as the data-gjs-traits='' which is setting traits empty What is the current behavior? If I will place there something else than empty string it will crush the grapes If is necessary to execute some code in order to reprodu...

Answers (2)

artfDecember 13, 2022

You should use properly parsable JSON strings eg, data-gjs-traits='["id"]', data-gjs-traits="[]"

GJSBlockMay 17, 2026

Thanks for reporting this, @edenizk. Great question about Can't set traits in attributes. The recommended approach with GrapesJS is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Most operations can be achie...

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 →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.