我正在为我的CI3项目使用ace-admin模板(http://ace.jeka.by/)。我想从我的观点中填充模式形式。如果我将模态代码放在同一视图上就可以了,例如:
<a href="#modal-table" role="button" class="green" data-toggle="modal">
<button class="btn btn-sm btn-default" id="myBtn">
<i class="ace-icon fa fa-plus align-top"></i>
Modal
</button>
</a>
<div id="modal-table" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header no-padding">
Results for "Latest Registered Domains
</div>
<div class="modal-body no-padding">
azerty
</div>
<div class="modal-footer no-margin-top">
<button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
<i class="ace-icon fa fa-times"></i>
Closee
</button>
</div>
</div>
</div>
</div>
但是,如果我更改href,将其发送给控制器,如下所示:
<a href="<?php echo base_url();?>ctl/add/" role="button" class="green" data-toggle="modal">
<button class="btn btn-sm btn-success" id="myBtn">
<i class="ace-icon fa fa-plus align-top"></i>
New
</button>
</a>
并在控制器上:
$this->theme_view = 'modal';
$this->render('parametres/utilisateurs/_new', $data);
渲染功能:
if (isset($this->theme_view)) {
$template = 'modal';
} else {
$template = 'master_view';
}
$name = 'contents';
$this->load->view('layouts/'.$template, $this->template_data);
以及模式布局:
<div id="modal-table" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header no-padding">
Results for "Latest Registered Domains
</div>
<div class="modal-body no-padding">
<?=$contents;?>
</div>
<div class="modal-footer no-margin-top">
<button class="btn btn-sm btn-danger pull-left" data-dismiss="modal">
<i class="ace-icon fa fa-times"></i>
Closee
</button>
</div>
</div>
</div>
</div>
该视图看起来不像模式形式,而是在新页面中显示。 任何想法吗?