How to preserve the Id attribute with toHTML
but now the id's are not in the html anymore Can you explain better your case because this new feature shouldn't change the previous behavior. BTW to explain this new option let's take for example a component that on component.toHTML() returns this: So now, for example, you can do this: to return
Read full answer below ↓Question
The changelog states
Added the possibility to output custom attributes in toHTML method
How do we use this feature? I cant find the corresponding issues, or any info on the options for the toHTML method in the wiki.
I used this function in 0.14.20 and earlier to post the html to the server and do some more processing on the html & css, but now the id's are not in the html anymore. I like to set it to preserve classes and id's.
Answers (3)
but now the id's are not in the html anymore Can you explain better your case because this new feature shouldn't change the previous behavior. BTW to explain this new option let's take for example a component that on component.toHTML() returns this: So now, for example, you can do this: to return
You're probably right. It's not this feature that's changed that behavior. Maybe its a bug, you can change the title of the issue if you confirm it. My test case: Template: Version 0.14.21 html output (from grapesjs.com/demo.html): Version 0.14.21 html output The css have the proper id's, but the h...
Thanks @Jogai, you're actually right, there is a bug (will be fixed for the next release), but I'd like to suggest to try this option which should also correct the current behaviour: One day or another, probably, this will be true by default, as without it you can't style single component on differ...
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1290
[BUG]Set href for link block not editable once initialized
#1277 is closed but issue still exist so i have to post as new issue Thank you for the help for earlier @maryia-kabash @artf I have made a...
Issue #6152
CSS added via custom code persists after custom code component is removed
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link https://grapesj...
Issue #1878
Issue in wiki from the last release
Hi, I have the same bug than the wiki. The panel layer, style, traits, etc... have some issue. How can i resolve this plz?
Issue #1579
Border Color Issue
@artf There is bug in the border color if you drag a button on the editor and paste color like rgb(255, 0, 0) in border color and select an...
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
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.
Tutorial
GrapesJS Inline RTE Plugins Update: CKEditor 5 v0.1.4 and Froala Inline Text Editor
CKEditor 5 Inline for GrapesJS v0.1.4 fixes Studio SDK toolbar clipping, iframe injection and link balloon bugs. Compare with Froala Inline — both $69.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.