gridstack.js issue base
Use this as a base for examples for gridstack.js issues.
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridstack@10.0.0/dist/gridstack.min.css">
<script src="https://cdn.jsdelivr.net/npm/gridstack@10.0.0/dist/gridstack-all.js"></script>
<h1>gridstack.js base demo for issues</h1>
<p>Fork and modify me to demonstrate your issue when creating an issue for gridstack.js</p>
<button onClick="addNewWidget()">Add Widget</button>
<div class="grid-stack" id="gs">
<div gs-w="6" gs-h="4" gs-auto-position="true" class="grid-stack-item grid-stack-sub-grid">
<div class="grid-stack-item-content">
<div class="grid-stack grid-stack-nested">
<div gs-w="3" gs-h="2" gs-auto-position="true" class="grid-stack-item">
<div class="grid-stack-item-content">
<div>
Subgrid
</div>
</div>
</div>
</div>
</div>
</div>
</div>
CSS
.grid-stack {
background: lightgoldenrodyellow;
}
.grid-stack-item-content {
color: #2c3e50;
text-align: center;
background-color: #18bc9c;
}
JavaScript
var options = { // put in gridstack options here
float: false,
acceptWidgets: true,
minRow: 1,
};
var grid = GridStack.init(options, '#gs')
let rows = GridStack.initAll({
...options,
column: 'auto',
},
'.grid-stack-nested',
)
console.log(rows.length)
let count = 0
addNewWidget = function() {
var node = {
x: Math.round(12 * Math.random()),
y: Math.round(5 * Math.random()),
w: Math.round(1 + 3 * Math.random()),
h: Math.round(1 + 3 * Math.random()),
content: String(count++)
};
grid.addWidget(node);
return false;
};