感谢早期的帮助(http://stackoverflow.com/questions/12224717/cant-execute-jquery-post-or-ajax-after-initial-run),现在重新绑定点击事件可以正常工作。但是,我似乎无法重新绑定对话框定义。从这里的其他答案中阅读,似乎答案在于使用“代表”,但我似乎无法弄清楚。这是带有对话框的更新代码:
$('[id^="del"]').live('click', function(){
var valname = $(this).attr('id').split('del_');
$.post("delthis.php", {id: ""+valname[1]+""}, function(data) {
$("#dynamic_section").html(data);
});
return false;
});
$('[id^="thismodal"]').dialog({
autoOpen: false,
show: 'blind',
hide: 'explode',
width: '760',
resizable: false,
modal: true
});
// Dialog Link
$('[id^="mlink"]').live('click', function(e) {
e.preventDefault();
var valname = $(this).attr('id');
var sname = valname.split("mlink_");
var modal = "#thismodal" + sname[1];
$(modal).dialog('open');
//return false;
});
// html
// loop
<div>
<p>
<a href='#' id='del_<?php echo $row['id']; ?>'>Delete <?php echo $row['id']; ?></a><br />
<a href='#' id='mlink_<?php echo $row['id']; ?>'>Show Modal <?php echo $row['id']; ?></a>
<div id='thismodal<?php echo $row['id']; ?>'>
This is the modal showing element # <?php echo $row['id']; ?>
</div>
</p>
</div>
// end loop
谢谢你。