I am using twitter boostrap data table in my page.In the same page i had called delete option for each row in a table.While i click the delete button in page1 it opens the confirm dialogue to delete a record,But its not working in other pages.Please refer my workout code here.
My code:
<!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>
Please help me how to fix the issue. Thanks