I’m trying to create a text edit in place myself just by manipulating jQuery selectors. But, after the first ajax callback, the others callback for the same input text doesn’t work anymore…
function editaVal(celDiv, id) { var novoConteudo = $('<input type='text' id='novoCont' + id + '' value='' + $(celDiv).html() + '' />'); $(celDiv).dblclick(function() { $(this).html(novoConteudo); }); $(novoConteudo).blur(function() { $(novoConteudo).parents('tr').removeClass('trSelected'); $.ajax({ type: 'POST', url: '/SuperAdmin/SalvaValor/?busca=' + $(novoConteudo).val() + '&codValor=' + id, beforeSend: function() { $(celDiv).html($('#loading').show()); }, success: function() { $(celDiv).html($('#loading').hide()); $(celDiv).html(novoConteudo.val()); } }); }); }
My question is: how can i rebind this??? Rebind the blur event… When I blur the input text, nothing happens on the second ajax callback.
thanks!!
You’re attaching a
'onblur'handler to an element that gets wiped out after the ajax update. If you want the event to persist, just bind it when you create it (ie on thedblclick):