Issue #1246💬 AnsweredOpened June 28, 2018by Jogai0 reactions

How to preserve the Id attribute with toHTML

Quick answerby artf

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)

artfJune 30, 2018

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

JogaiJuly 2, 2018

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...

artfJuly 5, 2018

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.

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.