Good morning, I currently generate a list of coupons dynamically in the following way:
var cupones_bienvenida = $('.cupones_bienvenida');
var tipoCupon ='';
$.each(response.data, function (i) {
if (response.data[i].Sub_Tipo == 1){
tipoCupon = "Cupón 1";
}
else if(response.data[i].Sub_Tipo == 2){
tipoCupon = "Cupón 2";
}
else{
tipoCupon = "Cupón 3";
}
$('<tr class="cupones"/>')
.append($('<td/>').addClass('nuevo-td td-cuponera-costarica')
.append($('<label/>').addClass('label-checkbox item-content').text(response.data[i].Nombre)))
.append($('<td/>').addClass('label-cell nuevo-td').append($('<p class="td-parrafor-cupcostarica"/>').text(tipoCupon))
.append($('<p class="td-parrafor-cupcostarica"/>').text("Descuento: "+response.data[i].Descuento)))
.append('<div class="cod_cupon" style="display:none">' + response.data[i].Identificador + '</div>')
.append('<div class="descuento_cupon" style="display:none">' + response.data[i].Descuento + '</div>')
.append('<div class="tipo_cupon" style="display:none">' + response.data[i].Tipo_cupon + '</div>')
.append('<div class="sub_tipo" style="display:none">' + response.data[i].Sub_Tipo + '</div>')
.append('<div class="vencimiento" style="display:none">' + response.data[i].Fecha_vence + '</div>')
.append($('<td/>').addClass('label-cell nuevo-td')
.append($('<label/>').addClass('label-checkbox item-content')
.append('<input type="checkbox" name="cupon_check" class="cupon_check" value="' + response.data[i].Identificador + '"/>')
.append($('<span/>').addClass('item-media').append('<i class="icon icon-form-checkbox"></i>'))))
.appendTo(cupones_bienvenida);
if (cantidad_llaves === 0) {
$('.cupon_check').prop('disabled', true)
}
});
$('.cupones_bienvenida').on('click','.cupon_check', function(e){
//Aca obtengo los valores del listado dinamico
});
It turns out that when selecting the checkboxes
Everything works well for me, the detail arises when I make a change of sight, for example I am in 'pagina / coupons.html' and then when I go to another view as 'pagina / principal.html', when returning to coupons.html the selected information has been deleted.
Then I intend to generate a json with the information of the coupons list. But I have the doubt as to how this json should be structured and then how to reload this json to the list so that the information is not affected, that is, it is only temporarily saved.