So I have this one weird situation which I am really confused now. I can't see any solution on the Net yet for this weird issue. I have one AJAX call that will populate the data which generated on the page also by using AJAX (dynamic). Here is my code:
My jQuery Code:
$(document).delegate('.edit_tr', 'click', function(){
var the_id = $(this).attr('id');
}).delegate('.edit_tr', 'keypress', function(e){
if(e.which == 13) {
var input_name = $("#input_name_" + the_id ).val();
if(input_name.length > 0){
//if I reset the span text and do return false here, the text showed properly on the page
$.ajax({
type: "POST",
url: "ajax_update.php",
data: data_string,
success: function(html){
//do the reset of span text
$('#name_'+the_id+'').html(input_name);
alert('Examining'); //while alert is popped up,text of span is expected as changed
//after 'OK' is clicked on the alert, the span text go back to its previous text
},
error: function(err){
//do something
}
});
}
}
});
Code in another PHP page which gets called via AJAX. This page displays the data on the page before being manipulated by above code for edit in place.
$returned_msg .= '<form id="form1">';
if( $contact_details->exists() ){
$lists = $contact_details->data();
foreach( $lists as $list ){
$returned_msg .= '<tr id = "'.$list->cont_detail_id.'" class="edit_tr">
<td style="text-align:center" class="edit_td">
<input type="hidden" value="'.$list->cont_detail_id.'" id="cont_detail_id_'.$list->cont_detail_id.'" />
<span id="name_'.$list->cont_detail_id.'" class="text_span">'.$list->det_name.'</span>
<input type="text" value="'.$list->det_name.'" style="width:120px;height:6px;" class="editbox" id="input_name_'.$list->cont_detail_id.'" />
<input type="hidden" value="'.$list->det_name.'" class="editbox" id="hidden_name_'.$list->cont_detail_id.'" />
</td>
</tr>';
}
$returned_msg .= '</form>';
}
class editbox
is not displayed till the tr
is clicked. I am now totally baffled. Looking forward to get some thought on what could probably causing this. Thank you.