使用模式引导程序作为codeigniter中的删除提示? [英] Use modal bootstrap as delete prompt in codeigniter?
本文介绍了使用模式引导程序作为codeigniter中的删除提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在查看或提示删除文本确认时遇到问题,我可以在提示中使用引导程序中的模式作为删除吗?
I have a problem about to view or prompt a delete text confirmation, can I use the modal in bootstrap in prompt as a delete?
我尝试过并且可以删除,但仅在第一个 id中没有特定的ID,并且我不知道要怎么做才能获得特定的ID。
I try and it can delete but in the first "id" only not in specific id and I don't know what to do to make specific 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>
推荐答案
使用此代码,您无需每次在视图中添加动态模态:)
Use this code you do not need to add dynamic modal each time in your view :)
<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>
这篇关于使用模式引导程序作为codeigniter中的删除提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文