4
I’m dealing with some current optimizations on my system and I found a situation that intrigued me,every time I double-clicked the table and called a function to bring the client’s complementary data the same doubled the amount of requests to php, This is because I was using the event on, then I performed some research and discovered the method one, running the method only once. this function appears to be new in versions 1.7 of Jquery used only the live and it worked properly.
So my doubt and the next, I must use one whether my intention is to call a function only once or should I use on and off ?
$('#clientes tbody').on('dblclick', 'tr', function () {
$('#cobradores tbody tr').removeClass('btn-success');
$(this).addClass('btn-success');
codigo = $(this).closest('tr').attr('id');
acao = 'update';
$("#clientes").modal('show');
});
$('#clientesModal').on('show.bs.modal', function () {
if (acao === 'update') {
dados = {PREUPDATE: true, CODIGO: codigo};
buscaCobradores(dados);
}
});
The letter E :) I don’t know jQuery but I believe that the new method was created precisely to avoid the situation you described.
– Maniero