Grapes js version v0.16.34 giving unexpected script code after loading saved html
kindly any one help me to get out of this issue editor.setComponents(html text ); not working the script as expected after loading from saved template html while drag and drop its working after saving and again loading that html with editor.setComponents(html text ); then the existing script replacing the symbols like...
Read full answer below ↓Question
attaching code:
while saving the html:
<div class="gjs-row">
<div class="gjs-cell">
<div class="gjs-row">
<div class="gjs-cell">
<div id="i6x6">
<div id="bsrne9exd5" style="height:300px" tg="DataGrid" tagName="DataGrid" class="ag-theme-alpine">
</div>
</div>
</div>
<div class="gjs-cell">
<div id="ibc4">
<div id="3drqn6v2q5" style="height:300px" tg="DataGrid" tagName="DataGrid" class="ag-theme-alpine">
</div>
</div>
</div>
</div>
</div>
</div>
<script>var items = document.querySelectorAll('#i6x6');
for (var i = 0, len = items.length; i < len; i++) {
(function(){
var columnDefs = [{
headerName: 'Make', field: 'make',sortable: true, filter: true}
, {
headerName: 'Model', field: 'model',sortable: true, filter: true}
,{
headerName: 'Price', field: 'price',sortable: true, filter: true}
];
var rowData = [{
make: 'Toyota', model: 'Celica', price: 35000}
,{
make: 'Ford', model: 'Mondeo', price: 32000}
,{
make: 'Porsche', model: 'Boxter', price: 72000}
];
var gridOptions = {
defaultColDef: {
resizable: true }
,columnDefs: columnDefs,rowData: rowData};
var gridDiv = document.getElementById('bsrne9exd5');
new agGrid.Grid(gridDiv, gridOptions);
}
.bind(items[i]))();
}
var items = document.querySelectorAll('#ibc4');
for (var i = 0, len = items.length; i < len; i++) {
(function(){
var columnDefs = [{
headerName: 'Make', field: 'make',sortable: true, filter: true}
, {
headerName: 'Model', field: 'model',sortable: true, filter: true}
,{
headerName: 'Price', field: 'price',sortable: true, filter: true}
];
var rowData = [{
make: 'Toyota', model: 'Celica', price: 35000}
,{
make: 'Ford', model: 'Mondeo', price: 32000}
,{
make: 'Porsche', model: 'Boxter', price: 72000}
];
var gridOptions = {
defaultColDef: {
resizable: true }
,columnDefs: columnDefs,rowData: rowData};
var gridDiv = document.getElementById('3drqn6v2q5');
new agGrid.Grid(gridDiv, gridOptions);
}
.bind(items[i]))();
}
</script>
after saving the code become:
<div class="gjs-row">
<div class="gjs-cell">
<div class="gjs-row">
<div class="gjs-cell">
<div id="iepv">
<div id="4h942l66s5" tg="DataGrid" tagname="DataGrid" class="ag-theme-alpine">
</div>
</div>
</div>
<div class="gjs-cell">
<div id="iiih">
<div id="l6r4s71nr5" tg="DataGrid" tagname="DataGrid" class="ag-theme-alpine">
</div>
</div>
</div>
</div>
</div>
</div>
<div id="loader" class="loader text-center d-none">
<div id="ie5kf" class="spinner-border text-primary">
</div>
<div id="iqy34">Processing.........
</div>
</div>
<input type="hidden" id="solutionName" name="solutionName" value="finalTest"/>
<input type="hidden" id="templateId" name="templateId" value="29742b00-897b-4f4e-9a58-4c8c63b9a8d8"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"/>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://unpkg.com/ag-grid-community/dist/ag-grid-community.min.js"></script>
<script src="/utils.js"></script>
<script id="script_initial">$(document).ready(function(event){
utils.initialize()}
);
</script>
<script>var items = document.querySelectorAll('#iepv');
for (var i = 0, len = items.length; i < len; i++) {
(function(){
var columnDefs = [{
headerName: '
Make'
, field: '
make'
,sortable: true, filter: true}
, {
headerName: '
Model'
, field: '
model'
,sortable: true, filter: true}
,{
headerName: '
Price'
, field: '
price'
,sortable: true, filter: true}
];
var rowData = [{
make: '
Toyota'
, model: '
Celica'
, price: 35000}
,{
make: '
Ford'
, model: '
Mondeo'
, price: 32000}
,{
make: '
Porsche'
, model: '
Boxter'
, price: 72000}
];
var gridOptions = {
defaultColDef: {
resizable: true }
,columnDefs: columnDefs,rowData: rowData};
var gridDiv = document.getElementById('4h942l66s5');
new agGrid.Grid(gridDiv, gridOptions);
}
.bind(items[i]))();
}
var items = document.querySelectorAll('#iiih');
for (var i = 0, len = items.length; i < len; i++) {
(function(){
var columnDefs = [{
headerName: '
Make'
, field: '
make'
,sortable: true, filter: true}
, {
headerName: '
Model'
, field: '
model'
,sortable: true, filter: true}
,{
headerName: '
Price'
, field: '
price'
,sortable: true, filter: true}
];
var rowData = [{
make: '
Toyota'
, model: '
Celica'
, price: 35000}
,{
make: '
Ford'
, model: '
Mondeo'
, price: 32000}
,{
make: '
Porsche'
, model: '
Boxter'
, price: 72000}
];
var gridOptions = {
defaultColDef: {
resizable: true }
,columnDefs: columnDefs,rowData: rowData};
var gridDiv = document.getElementById('l6r4s71nr5');
new agGrid.Grid(gridDiv, gridOptions);
}
.bind(items[i]))();
}
</script>
editor.setComponents(HTML String); changing ' to ' like all the symbols like < or >are changin to browser undestanding way kindly help me out to resolve thisAnswers (3)
kindly any one help me to get out of this issue editor.setComponents(html text ); not working the script as expected after loading from saved template html while drag and drop its working after saving and again loading that html with editor.setComponents(html text ); then the existing script replacing the symbols like ' < > with browser related codes and this is happening in version v0.16.34 only
You can't load the generated HTML code back to the editor, read the documentation on how to correctly store and load templates https://grapesjs.com/docs/modules/Storage.html
Thanks for reporting this, @nithinpillalamarri123.
Thanks for sharing your report about grapes js version v0.16.34 giving unexpected script code after loading saved html. To help the team investigate and prioritize this:
Please provide:
- A minimal reproducible example (CodeSandbox/JSFiddle)
- Your GrapesJS version number
- Browser and OS information
- Any error messages from the browser console
- Steps to reproduce the issue
What helps most:
- Minimal code example (not your full project)
- Screen recording or screenshot showing the issue
- Expected vs actual behavior clearly stated
- GrapesJS configuration you're using
With these details, the maintainers can identify and prioritize a fix much faster. The GrapesJS team is very responsive to well-documented issues.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3116
[HELP WANTED] How to load css that can viewed in code viewer and also exported while saving
Hi :wave: I am trying to load some CSS within the editor as part of the theme, I am able to link stylesheets as part of loading but the pro...
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 #3512
Child elements not draggable ,droppable highlightable. also the CSS of all child elements not pushed in style section while develop a banner component in as plugin
Hello @artf , I am trying to develop a simple banner plugin which will be include a heading , subheading and link. and every element can be...
Issue #5090
Component script function runs twice after page save
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? 112.0.5615.137 (Official Build) (arm64) Re...
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 →Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.