Jump to content

2.3.9 Nested — Views Codehs

// create an item (child view) const item = document.createElement('li'); item.textContent = 'Click me'; item.className = 'item';

function ListView(items) { const container = createDiv('list'); items.forEach(it => { const row = RowView(it, selected => console.log('selected', selected)); container.appendChild(row); }); return container; } Benefit: RowView is reusable and isolated. 2.3.9 nested views codehs

// nest item inside list, list inside app list.appendChild(item); app.appendChild(list); // create an item (child view) const item = document

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.