I have a problem with calling a modal popup from controller... in this case i use datatables, and i want to make edit form as a modal popup... someone can help me...??
here's my controller :
function datatables(){
$this->load->library('Datatables');
$this->datatables->from('tb_rekap_wo_tj');
$this->datatables->select('tj_id, tj_tanggal, tj_waktu_mulai, tj_waktu_selesai, tj_halte, tj_koridor, tj_teknisi1, tj_teknisi2, tj_petugas_halte, tj_permasalahan, tj_penanganan, tj_status, tj_keterangan');
$this->datatables->add_column('edit', '<a href="wo_gt/edit/$1" title="Edit" onclick="wo_gt/edit/$1"><button class="btn btn-warning btn-sm"><i class="fa fa-pencil"></i></button></a> <a href="wo_gt/delete/$1"><button class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></button></a>', 'tj_id');
echo $this->datatables->generate();
}
public function edit($id) {
$this->load->model('wo_model');
$data = $this->wo_model->get_by_id($id);
echo json_encode($data);
}
here's the result :
so my question is... how to show the result as a modal popup...?? Thanks...
答案 0 :(得分:0)
您可以从HTML表单开始
<div id="overlay" class="modal_overlay"></div>
<div id="dialog" class="modal_window">
"here comes the table or whatever you wish to input and alter data you get from your tables."
</div>
您可能还需要一个像这样的“编辑”按钮:
<input type="button" id="btnShowModal" value="Modal Dialog" />
然后添加一些CSS:
<style type="text/css">
.modal_overlay
{
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 100%;
width: 100%;
margin: 0;
padding: 0;
background: #000000;
opacity: .15;
filter: alpha(opacity=15);
-moz-opacity: .15;
z-index: 101;
display: none;
}
.modal_window
{
display: none;
position: fixed;
width: 380px;
height: 200px;
top: 50%;
left: 50%;
margin-left: -190px;
margin-top: -100px;
background-color: #ffffff;
border: 2px solid #336699;
padding: 0px;
z-index: 102;
font-family: Verdana;
font-size: 10pt;
}
和JS来解雇这个事件。
<script type="text/javascript">
$(document).ready(function ()
{
$("#btnShowModal").click(function (e)
{
ShowDialog();
e.preventDefault();
});
$("#btnClose").click(function (e)
{
HideDialog();
e.preventDefault();
});
$("#btnSubmit").click(function (e)
{
//submit logic
HideDialog();
e.preventDefault();
});
});
function ShowDialog()
{
$("#overlay").show();
$("#dialog").fadeIn(300);
$("#overlay").unbind("click");
}
function HideDialog()
{
$("#overlay").hide();
$("#dialog").fadeOut(300);
}
</script>
基本上你有一个叠加层使得东西看起来是模态的,一旦你解开“点击”它也会有这种感觉。我现在没有尝试过这个特殊的代码,但是我使用这种技术做了几次模态窗口。