我在我的頁面中使用twitter boostrap數據表。我在同一個頁面中爲表格中的每一行調用了刪除選項。雖然我單擊頁面1中的刪除按鈕,但它會打開確認對話框以刪除記錄,但它不會在其他網頁工作。請參閱我的鍛鍊代碼在這裏。在twitter boostrap數據表中,確認對話框在其他頁面不起作用的page1上工作?
我的代碼:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Data table with all features</title>
<link href="css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<br>
<div style="width:900px; margin:0 auto; border:0px green dashed;" align="center">
<table class="table table-bordered" id="sample_1">
<thead>
<tr><th>Message</th> <th>Phone</th><th>Event Date</th><th>Message ID</th><th>Institution ID</th></tr>
</thead>
<tbody>
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
mysql_connect('localhost','root','');
mysql_select_db('sams');
$data = mysql_query("SELECT * FROM (SELECT 1 AS type,institution_id,message,phone,event_date,message_id FROM custom_messages UNION ALL SELECT 2 AS type,institution_id,message,phone,event_date,message_id FROM send_messages) T1 where institution_id = '11' ORDER BY event_date");
$sno = 0;
while($record = mysql_fetch_assoc($data))
{
?>
<tr>
<td><?php echo $record['message']; ?></td>
<td><?php echo $record['phone']; ?></td>
<td><?php echo $record['event_date']; ?></td>
<td><?php echo $record['institution_id']; ?></td>
<td><a id=simpleConfirm_<?php echo $sno; ?>" custom-attr="destroy<?php echo $sno; ?>" href="#" class="delete">Delete</a></td>
</tr>
<?php
$sno++;
}
?>
</tbody>
</table>
</div>
<script src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/DT_bootstrap.js"></script>
<script src="js/dynamic-table.js"></script>
<script>
$(function(){
$('.delete').on('click',function(){
var data = $(this).attr('custom-attr')
confirm(data)
})
})
</script>
</body>
</html>
請幫助我如何解決這個問題。 感謝
太好了。這對我很有幫助。 – ahalya