湛蓝的天 发表于 2016-7-18 19:01:51

怎么自定义提示框

在Commen.php里自定义个函数
function error($msg){
    header('Content-Type:text/html;charset=utf-8');
    echo "<script type='text/javascript'>alert('$msg');window.history.back();</script>";
    die;
}
然后在控制器调用,现在想自定义个提示框,怎么搞

湛蓝的天 发表于 2016-7-19 21:33:22

没人么?

湛蓝的天 发表于 2016-7-20 00:10:31

来人啊

Hex 发表于 2016-7-20 10:53:51

你这个功能为什么要用 PHP 实现,应该是 JS 做的事情,你的思路就错了。

湛蓝的天 发表于 2016-7-20 21:02:08

可以在php里写个提示框,然后js控制显示隐藏,比如这个
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
    <p>One fine body…</p>
</div>
<div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
    <button class="btn btn-primary">Save changes</button>
</div>
</div>
点击按钮它就弹出来了
<script type="text/javascript">
    $(document).ready(function(){
    $('#bb').click(function(){
      $('#myModal').modal();
    });
});
    </script>

湛蓝的天 发表于 2016-7-20 21:05:31

但这样是在php(视图)里写,感觉要写个ajax发送数据到控制器,然后返回数据,再根据数据弹出提示框,感觉好麻烦

湛蓝的天 发表于 2016-7-20 21:07:39

在commen.php定义全局函数,在控制器就可调用,就不用ajax了

湛蓝的天 发表于 2016-7-20 21:08:51

我是新手,不怎么会求指教

湛蓝的天 发表于 2016-7-20 21:10:30

还有个问题,apache 和 ci都设置了Acia/Shanghai时区,但跟我电脑时间还是差半个小时:Q
页: [1]
查看完整版本: 怎么自定义提示框