1
I have a code that was working and from one day to the next it stopped working, I don’t understand why this !!
It’s not even firing the event ...
I followed the code below:
<table style="width: auto;" id="tblEditavel" >
<thead>
<tr>
<th style=" text-align: center; width: 50px; ">Valor</th>
</tr>
</thead>
<tbody>
<tr>
<td class="editavel" style="text-align: center; width: auto ; font-weight: bold;"> abc </td>
</tr>
</tbody>
</table>
js come here:
jQuery(function($) {
$('#tblEditavel tbody tr td.editavel').dblclick(function(){
//$('.editavel').dblclick(function(){
if($('td > input').length > 0){ // verifica se já existe algum input já na <td>
return;
}
console.log('teste');
var conteudoOriginal = $(this).text();
var novoElemento = $("<input type='text' value='"+trim(conteudoOriginal)+"' class='campo_altera' />");
$(this).html(novoElemento.bind('blur keydown', function(e){
var keyCode = e.which;
var conteudoNovo = $(this).val();
if(keyCode == 13 && conteudoNovo != '' && conteudoNovo != conteudoOriginal){
var objeto = $(this);
$.ajax({
type:"POST",
url:"assets/php/alterar_vt.php",
data:{
valor_antigo:conteudoOriginal,
valor_novo:conteudoNovo
},
success:function(result){
objeto.parent().html(conteudoNovo);
$('body').append(result);
}
})
}else if( keyCode == 27 || e.type == 'blur')
$(this).parent().html(conteudoOriginal);
}));
$(this).children().select();
});
});
you are using which browser ? presses F12 and goes on console and see if it is written something and put here
– Marcos Brinner
I use Chrome amg, it is updated in the latest version and the event does not fire ... check that I put a console.log() to see if it is triggering the event and nothing appears.
– Thiago Lopez