0
I am trying to create a "table" with Divs with dynamically retrieved data from localStorage.
I can recover the data and create the elements, but not in the desired way. The data is being duplicated inside the div (which in fact was the only one that should repeat).
My goal is to create a structure like this for each object recovered from localStorage:
EXPECTED STRUCTURE FOR EACH OBJECT:
<div class="row align-items-center w-100" id="cadastroCliente">
<div> <!--DIV QUE TEM QUE REPETIR PARA CADA OBJETO-->
<div class="col-lg-3">
<div class="col">Nome</div>
<div class="col">Email</div>
</div>
<div class="col-lg-3">
<div class="col" style=>CPF</div>
<div class="col" style=>TEL</div>
</div>
<div class="col-lg-3">
<div class="col">Status</div>
</div>
<div class="col-lg-3">
<button type="button" class="btnCustom float-r mr-3">Editar</button>
</div>
</div>
</div>
I’m trying to create it this way:
in HTML:
<div class="row" id="listaClientes"></div>
JS:
//FUNCTION PARA CRIAR A DIV DE FORMA DINAMICA
function listaCliente(clientes = Array(), filter = false) {
if(clientes.length == 0 && filter == false) {
clientes = bd.recuperarClientes()
}
let listaCliente = document.getElementById('listaClientes')
clientes.forEach(function(d) {
$('#listaClientes').append(`<div class="col-lg-3 divCustom"></div>`);
I’m managing to create the div I want you to repeat for each Object, but I’m not sure how to insert dynamic data into this div.
Our very simple. I was thinking of creating dynamic id to try to solve =) Thanks!
– felipenoka