Skip to content

revert not ready nested.html #2814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions demo/nested.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ <h1>Nested grids demo</h1>
})

// setup drag drop behavior
let sidebarContent = [
{ w:2, h:2, subGridOpts: { children: [{content: 'nest 1'}, {content: 'nest 2'}]}}
];
GridStack.setupDragIn('.sidebar .grid-stack-item', undefined, sidebarContent);
GridStack.setupDragIn('.sidebar .grid-stack-item', { appendTo: 'body', helper: 'clone' });

function addWidget() {
grid.addWidget({x:0, y:100, content:"new item"});
Expand Down Expand Up @@ -116,7 +113,15 @@ <h1>Nested grids demo</h1>
n.el.querySelector('.grid-stack-item-content').innerHTML = '';
let nodeToAdd = { children: [{content: 'nest 1'}, {content: 'nest 2'}]};
let subgrid = n.grid.makeSubGrid(n.el, nodeToAdd, undefined, false);

// add a listener to the subgrid to allow widgets to be added into this newly created nested widget
subgrid.on('dropped', droppedHandler);
}
// add listener to the main grid and subgrids
grid.on('dropped', droppedHandler);
document.querySelectorAll('.grid-stack-nested').forEach((subGrid) => {
subGrid.gridstack.on('dropped', droppedHandler);
});

//--- end of Drag and Drop Nested widget logic

Expand All @@ -137,6 +142,7 @@ <h1>Nested grids demo</h1>
function load(full = true) {
if (full) {
grid = GridStack.addGrid(document.querySelector('.container-fluid'), options);
grid.on('dropped', droppedHandler);
} else {
grid.load(options);
}
Expand Down