In my next code below I would like to insert the data coming from the ajax request, along with the append () HTML only in elements whose input hidden ids are equal to item.id
(of objItens
). But all the ways I figured out did not work. Any tips on how I can implement this in the best way?
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'
);
}
}