I have some entries that have the option to filter alphabetically by name .. I enter these entries through append like this:
$(".listagem").append(
'<div class="row" id="corpo-cartoes">
<div class="col s12 m7" style="width: 100%;">
<div class="card">
<a href="cartao.html#${lastId}">
<div class="card-image">
<div class="gradient-cartao-lista"></div>
<img src="${capa}">
<span class="card-title"><h1>${data.card.empresa}</h1><p>${data.card.code}</p></span>
</div>
</a>
<div class="card-action icone-meu-cartao">
<a href="#"><i class="material-icons">star</i></a>
<a href="#"><i class="material-icons">crop_free</i></a>
<a href="#"><i class="material-icons">visibility</i></a>
<a href="cadastro-cartao.html#${lastId}"><i class="material-icons btn-editar">edit</i></a>
</div>
</div>
</div>
</div>'
);
Visually looks like this:
Iwouldliketosortthemalphabeticallybyname.
Atmybank,Ihavethesefields:
To get the name of my existing records I do:
var db = getDataBase();
db.transaction(function(tx){
tx.executeSql('SELECT nome FROM cartoes', [], function(tx, results){
for(i=0; i<results.rows.lenght; i++){
var nome = results.rows.item(i).nome;
console.log(nome);
}
});
});
How do I get and update them in my list that was inserted with append when the user wants to sort by name?