我有查看或提示删除文本确认的问题,我可以在提示中使用模式作为删除吗?
我尝试它可以删除,但在第一个“id”中只有不在特定的ID中,我不知道如何做出特定的id。
这是我的观点:
<div class="table-responsive">
<?php if(sizeof($query) < 1) : ?>
No record in the database.
<?php else : ?>
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>TITLE</th>
<th>CONTENT</th>
<th>LAST UPDATE</th>
<th>ACTIONS</th>
</tr>
</thead>
<tbody>
<?php foreach($query as $record) : ?>
<tr>
<td><?php echo $record->Id; ?></td>
<td><?php echo word_limiter($record->Title, 5); ?></td>
<td><?php echo word_limiter($record->Paragraph, 15); ?></td>
<td><?php echo $record->Lastupdate; ?></td>
<td>
<div class="btn-group btn-group-sm">
<a href="<?php echo base_url('gallery/view').'/'.$record->Id; ?>" class="btn btn-info">View</a>
<a href="#" class="btn btn-success">Edit</a>
<a href="" class="btn btn-danger" data-toggle="modal" data-target="#myModal">Delete</a>
</div>
</td>
</tr>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Delete</h4>
</div>
<div class="modal-body">
<p>Are you sure want to delete? </p>
</div>
<div class="modal-footer">
<a href="<?php echo base_url('Mywelcomepage/deletez').'/'.$record->Id; ?>" class="btn btn-default" >Yes</a>
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
答案 0 :(得分:3)
试试这个编码..
我已动态生成模型弹出窗口
<div class="table-responsive">
<?php if(sizeof($query) < 1) : ?>
No record in the database.
<?php else : ?>
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>TITLE</th>
<th>CONTENT</th>
<th>LAST UPDATE</th>
<th>ACTIONS</th>
</tr>
</thead>
<tbody>
<?php foreach($query as $record) : ?>
<tr>
<td><?php echo $record->Id; ?></td>
<td><?php echo word_limiter($record->Title, 5); ?></td>
<td><?php echo word_limiter($record->Paragraph, 15); ?></td>
<td><?php echo $record->Lastupdate; ?></td>
<td>
<div class="btn-group btn-group-sm">
<a href="<?php echo base_url('gallery/view').'/'.$record->Id; ?>" class="btn btn-info">View</a>
<a href="#" class="btn btn-success">Edit</a>
<a href="" class="btn btn-danger" data-toggle="modal" data-target="#myModal<?php echo $record->Id; ?>">Delete</a>
</div>
</td>
</tr>
<div id="myModal<?php echo $record->Id; ?>" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Delete</h4>
</div>
<div class="modal-body">
<p>Are you sure want to delete? </p>
</div>
<div class="modal-footer">
<a href="<?php echo base_url('Mywelcomepage/deletez').'/'.$record->Id; ?>" class="btn btn-default" >Yes</a>
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
答案 1 :(得分:3)
使用此代码,您不需要每次在视图中添加动态模态:)
<div class="table-responsive">
<?php if(sizeof($query) < 1) : ?>
No record in the database.
<?php else : ?>
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>TITLE</th>
<th>CONTENT</th>
<th>LAST UPDATE</th>
<th>ACTIONS</th>
</tr>
</thead>
<tbody>
<?php foreach($query as $record) : ?>
<tr>
<td><?php echo $record->Id; ?></td>
<td><?php echo word_limiter($record->Title, 5); ?></td>
<td><?php echo word_limiter($record->Paragraph, 15); ?></td>
<td><?php echo $record->Lastupdate; ?></td>
<td>
<div class="btn-group btn-group-sm">
<a href="<?php echo base_url('gallery/view').'/'.$record->Id; ?>" class="btn btn-info">View</a>
<a href="#" class="btn btn-success">Edit</a>
<a href="" class="btn btn-danger" data-toggle="modal" onclick="confirm_modal('<?php echo site_url("controller/function/".$record->Id);?>','Title');" data-target="#myModal">Delete</a>
</div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<!-- (Normal Modal)-->
<div class="modal fade" id="modal_delete_m_n" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog">
<div class="modal-content" style="margin-top:100px;">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" style="text-align:center;">Are you sure to Delete this <span class="grt"></span> ?</h4>
</div>
<div class="modal-footer" style="margin:0px; border-top:0px; text-align:center;">
<span id="preloader-delete"></span>
</br>
<a class="btn btn-danger" id="delete_link_m_n" href="">Delete</a>
<button type="button" class="btn btn-info" data-dismiss="modal" id="delete_cancel_link">Cancel</button>
</div>
</div>
</div>
</div>
<script>
function confirm_modal(delete_url,title)
{
jQuery('#modal_delete_m_n').modal('show', {backdrop: 'static',keyboard :false});
jQuery("#modal_delete_m_n .grt").text(title);
document.getElementById('delete_link_m_n').setAttribute("href" , delete_url );
document.getElementById('delete_link_m_n').focus();
}
</script>
<?php endif; ?>
</div>
&#13;