javascript - jQuery: Can't retrieve an attribute of a dynamically created DOM element -


here's situation: i'm writing simple ajax application performs crud functions. when user double clicks on particular element, element changes text box can edit inline. when text box loses focus (code below), value of textbox gets posted php script updates database.

all groovy except 1 thing. when create new record, gets popped onto top of list ajax, can't edit record without refreshing page. mean, edit looks it's been committed, when refresh, reverts original. after refreshing, there no issues.

to boil down: when try run following code on newly created rows in table (both in database , on page), edit appears made on page, never makes database.

//make changes on focusout     $('#editable').live('focusout', function(){         var parentlistitem = $(this).parents('li');         var thetext = $(this).val();         var parentlistitemid = parentlistitem.parents('ul').attr('id');          $(this).remove();         parentlistitem.html(thetext);         parentlistitem.removeclass('beingedited');          $.post("databasefuncs.php?func=edit", { postedmessage: parentlistitemid, fulltextcontent: thetext },             function(result){                 if(result == 1) {                     parentlistitem.parents('ul').animate({ backgroundcolor: 'blue' }, 500).animate({ backgroundcolor: '#eeeeee' }, 500);                 } else {                     alert(result);                 }              });      }); 

i suppose not binding event new dom element loaded via ajax.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -