0
In my following code below I would like to insert the data coming from the ajax request, along with the append() HTML only in the elements whose Hidden input id was equal to the item.id
(of objItens
). But all the ways I’ve imagined don’t work. Any hint on how I can best implement this?
function listaItensPorIdExecCadeia(objIdExecCadeia){
var idExecucaoDaCadeia = [];
objIdExecCadeia.map(cadeia => {
$('#bloco-procedimento-lista-itens').append(`
<h4>${cadeia.nome} #${cadeia.id}</h4>
<input id="inputIdExecucaoDaCadeia" type="hidden" value="${cadeia.id}" />
<ul id="procedimento-lista-itens" class="list-group">
</ul>
`);
idExecucaoDaCadeia.push(cadeia.id);
});
for(var i = 0; i <= idExecucaoDaCadeia.length; i++){
$.get(BASE_URL+'item/listar',{
idItem: idExecucaoDaCadeia[i],
},
function(objResponse){
var objItens = objResponse.strMessage;
objItens.map(item => {
$('#procedimento-lista-itens').append(`
<li class="list-group-item cadeia-itens-lista">
<p>${item.nome}</p>
<div>
<a class="btn btn-default"><i class="fa fa-qrcode"></i></a>
<a class="btn btn-primary"><i class="fa fa-info-circle"></i></a>
<a class="btn btn-warning"><i class="fa fa-edit"></i></a>
<a class="btn btn-danger"><i class="fa fa-times"></i></a>
</div>
</li>
`);
})
},'JSON'
);
}
}
What exactly is the mistake?
– Leandro Angelo