使用的是 bootstrap 4 和 bootboxjs
view
<?php echo form_open('panel/webconfig_post',array('class'=>'pt-4'));?>
...
...
<button class="btn btn-primary mr-5" type="submit" id='kk'>提交</button>    
<button class="btn btn-danger ml-5" type="reset">重置</button>
js
<script>
$(document).on("click", "#kk", function(e) {
    bootbox.confirm({
    message: "确定要提交吗?",
    locale: 'zh_CN',
    callback: function (result) {
        console.log(result);
        }
    });
});
</script>
想问下怎么写 js 才能点击窗口的确定之后再提交呢?
现在的情况是,点击提交,出现弹窗,但是不用点击直接提交表单到panel/webconfig_post这个控制器了
不会 js 😂
感谢@commoccoom,已经按照链接中的方法成功了
<script type="text/javascript">
    // 表单提交前询问确认
    $('#webconfig_form').submit(function(e) {
        var currentForm = this;
        e.preventDefault();
        bootbox.confirm({            
            message: "确定要提交吗?",
            locale: 'zh_CN',        
            callback: function(result) {
            if (result) {
                currentForm.submit();
                }
            }
        });
    });
</script>
|  |      1U2Fsd      2020-02-09 20:24:04 +08:00 LZ 不看文档的吗? ``` bootbox.confirm({ message: "This is a confirm with custom button text and color! Do you like it?", buttons: { confirm: { label: 'Yes', className: 'btn-success' }, cancel: { label: 'No', className: 'btn-danger' } }, callback: function (result) { console.log('This was logged in the callback: ' + result) } }) ``` | 
|  |      2U2Fsd      2020-02-09 20:25:29 +08:00 result 会返回 true 或者 false | 
|  |      6commoccoom      2020-02-10 10:49:29 +08:00  1 |