1
I write my table this way:
for (var i = pagina * tamanhoPagina; i < data.length && i < (pagina + 1) * tamanhoPagina; i++) {
Ida = data[i][0];
Paraa = data[i][9];;
tbody.append(
$('<tr class="table__row">')
.append($('<td class="table__content" data-heading="De" ${ Status } != "0"?" style="font-weight:bold; font-size: 90%" ":" style="font-weight:normal; font-size: 90%"">').append(data[i][1]))
.append($('<td class="table__content" data-heading="Tipo" ${ Status } != "0"?" style="font-weight:bold; font-size: 90%" ":" style="font-weight:normal; font-size: 90%"">').append(data[i][8]))
.append($('<td class="td-info apagar table__content" data-heading="Assunto" data-alerta="${ Ida }, ${ Paraa }" ${ Status } != "0"?" style="font-weight:bold; font-size: 90%" ":" style="font-weight:normal; font-size: 90%" ">').append(data[i][2]))
.append($('<td class="table__content" data-heading="Conteúdo" ${ Status } != "0"?" style="font-weight:bold; font-size: 90%" ":" style="font-weight:normal; font-size: 90%"">').append(data[i][3]))
.append($('<td class="table__content" data-heading="Estado" ${ Status } != "0"?" style="font-weight:bold; font-size: 90%" ":" style="font-weight:normal; font-size: 90%"">').append(data[i][4]))
.append($('<td class="table__content" data-heading="Recebido" ${ Status } != "0"?" style="font-weight:bold; font-size: 90%" ":" style="font-weight:normal; font-size: 90%"">').append(data[i][5]))
)
In this line:
.append($('<td class="td-info apagar table__content" data-heading="Assunto" data-alerta="${ Ida }, ${ Paraa }" ${ Status } != "0"?" style="font-weight:bold; font-size: 90%" ":" style="font-weight:normal; font-size: 90%" ">').append(data[i][2]))
I intend to take the variable Ida
and Paraa
to remove the line in the database. If console.log(Ida); console.log(Paraa);
before the tbody.append(
the variables have the correct value, but in the row does not send the values of the variables only the name.
Inside the line I got this way: data-alerta="${ Ida }, ${ Paraa }"
but this way the variables do not receive the values.
The js
to delete the line in the database is this:
function deletar(){
var ids = []; //arraypara armazenar os id's a serem deletados
$(".colorir").each(function(){ //percorre todos os tr que possui a classe colorir
ids.push($(this).find(".apagar").attr("data-alerta")); //adiciona o id da linha ao array
$(this).remove();
})
console.log(ids);
$.ajax({
url: './delalerta',
type: 'POST',
cache: false,
data: {ids:ids},
error: function(){
},
success: function(result)
{
}
});
//szer a chamada para remo褯 das linhas no php
}
To use the syntax
${variável}
, the string should be delimited by ``` instead of quotation marks. Ex: https://answall.com/a/78768/112052– hkotsubo
@hkotsubo if put date-alert=
${ Ida }, ${ Paraa }
sends the empty variables– Bruno
I meant:
append($(\
<td class=etc date-alert="${ Ida } etc`)). Toda a string delimitada por
`em vez das aspas - agora não vou conseguir testar, mas pra usar essa sintaxe tem que ser assim, com
``– hkotsubo
@hkotsubo is just that. It worked
– Bruno
@Bruno how you call that function
deletar
? can show this Handler Event that listens to the click?– Sergio