大家好我想在从我的表中删除记录之前使用bootstrap模式作为确认。
到目前为止我尝试了什么:
<script type="text/javascript">
$(function(){
$(".btn-show-modal").on('click', function(e){
e.preventDefault();
var id = $(this).attr('id');
var modal_id = "modal"+id;
$("#"+modal_id).modal('show');
});
$(".btn btn-danger").on('click', function(e){
var id = $(this).attr('id');
var modal_id = "modal"+id;
$("#"+modal_id).modal('hide');
});
});
</script>
View.php
<tbody>
<?php foreach ($sale_list as $u_key){ ?>
<tr>
<td><?php echo $u_key->sales_id; ?></td>
<td><?php $formatted_date = strtotime($u_key->transaction_date);
echo date('F d, Y H:i:s A', $formatted_date); ?></td></td>
<td><?php echo $u_key->product_code; ?></td>
<td><?php echo $u_key->trace_number; ?></td>
<td><?php echo '0' .$u_key->recipient; ?></td>
<td><?php echo $u_key->is_paid; ?></td>
<td><?php echo $u_key->load_balance; ?></td>
<td><?php echo anchor('customer/view_customer/' . $u_key->customer_id, $u_key->c_fname . ' ' . $u_key->c_lname, array('title' => 'View Customer')); ?></td>
<td>
<?php
echo anchor('sales/view_sale/' . $u_key->sales_id, '<span class="glyphicon glyphicon-search"></span>', array('title' => 'View Record') ) . ' | ' .
anchor('sales/edit_sale/' . $u_key->sales_id, '<span class="glyphicon glyphicon-pencil"></span>', array('title' => 'Update Record') ) . ' | ' .
anchor('#modal', '<span class="glyphicon glyphicon-remove"></span>',
array('title' => 'Delete Record', 'data-toggle' => 'modal', 'class' => 'btn-show-modal', 'id' => $u_key->sales_id ) );
?>
</td>
</tr>
<?php }?>
</tbody>
但这不起作用。我需要将id传递给我的jquery代码,但我不知道该怎么做。