For each card registered, I redirect the user to his card viewing page and there ready all the cards he has already registered.
Each card has its nome
, so for each card I create layout
and enter nome
. So far so good.
I'm doing this:
tx.executeSql('SELECT empresa FROM cartoes', [], function(tx, results){
for (var i=0; i<results.rows.length; i++) {
var nomes = results.rows.item(i);
cartoesCadastrados(); //essa função cria o layout
console.log(Object.values(nomes));
$('.row').find('span').text(Object.values(nomes));
}
This console.log(Object.values(nomes));
returns the names of the already registered cards:
["Ebcard"]
["Claro"]
["Itaú"]
This is where the problem lives:
$('.row').find('span').text(Object.values(nomes));
My intention in this code above is that for every% of% created, enter its layout
. The problem is that it inserts the same name for everyone, the last one that has been registered, in which case the 3 registered cards are with nome
of nome
.
Does anyone know what it can be?
The display layout of the registered card is as follows:
<html>
<div class="container">
<div class="row">
<!-- onde vai plotar o template -->
<div id="container"></div>
</div>
</div>
<template>
<div class="row" id="corpo-cartoes">
<div class="col s12 m7" style="width: 100%;">
<div class="card">
<div class="card-image">
<img src="img/apresentacao.jpg">
<span class="card-title">Card Title</span>
</div>
<div class="card-action icone-meu-cartao">
<a href="#" ><i class="material-icons">code</i></a>
<a href="#"><i class="material-icons">crop_free</i></a>
<a href="#"><i class="material-icons">visibility</i></a>
<a href="#"><i class="material-icons btn-editar">edit</i></a>
</div>
</div>
</div>
</div>
</template>
</html>
<script>
function cartoesCadastrados() {
var content = document.querySelector('template').content;
document.querySelector('#container').appendChild(
document.importNode(content, true));
}
</script>