Populate the grid dynamically
This commit is contained in:
parent
c6a84321d4
commit
dda80df882
4 changed files with 25 additions and 4 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
#mode {
|
||||||
|
list-style: none;
|
||||||
|
}
|
|
@ -8,10 +8,10 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<ul id="mode">
|
<ul id="mode">
|
||||||
<li id="edit"></li>
|
<li id="edit">Édition</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="playground">
|
<div id="playground">
|
||||||
<div id="grid"></div>
|
<table id="grid"></table>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
18
js/Grid.js
Normal file
18
js/Grid.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import * as Dom from UnitJS.Dom;
|
||||||
|
|
||||||
|
var size = 8;
|
||||||
|
|
||||||
|
return {
|
||||||
|
init: init
|
||||||
|
}
|
||||||
|
|
||||||
|
function init(elementId) {
|
||||||
|
var gridElement = document.getElementById(elementId || 'grid');
|
||||||
|
for(var row = 0; row < size; row++) {
|
||||||
|
var cells = [];
|
||||||
|
for(var column = 0; column < size; column++) {
|
||||||
|
cells.push(Dom.make('td'));
|
||||||
|
}
|
||||||
|
gridElement.appendChild(Dom.make('tr', {}, cells));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,3 @@
|
||||||
import * as Dom from UnitJS.Dom;
|
import Grid;
|
||||||
|
|
||||||
console.log('plip');
|
Grid.init();
|
||||||
|
|
Loading…
Reference in a new issue