I created a HTML Page which we can dynamically add rows and columns using JS. I would like to implement dragula jQuery for dragging both row and column draggable, like other column can draggable to different rows or blank rows. Looking for solution
HTML
<div class="wrapper">
<div class="main-content">
<div class="header">
<button class="add-row" onclick="addRow()">Add Row +</button>
<button class="add-column" onclick="addCol()">Add Column +</button>
</div>
<div class="container-box" id="contentBox">
</div>
</div>
</div>
here the id contentBox is the container div which appending rows and columns
JS
var i=0;
var j=0;
let newColNode = null;
function addRow() {
const row = document.createElement('div');
row.className = 'block';
row.id = "b" + ++i;
document.getElementById('contentBox').append(row);
row.addEventListener('click', function (event) {
console.log(newColNode)
console.log(row)
if(newColNode != null )
row.appendChild(newColNode);
newColNode = null
});
}
// Column Addition
function addCol() {
const col = document.createElement('div');
col.className = 'block-inner';
col.id = "c" + ++j;
col.textContent = `Column ${j}`;
newColNode = col;
}
in this code, added both add row and add column button function. There is requirement reference url and jsfiddle url which is adding below
Thanks in advance.
Dragula documentation: https://github.com/bevacqua/dragula
requirement reference URL: https://codepen.io/gabouh/pen/ZXrMzW