【问题标题】:input file style does not work in bootbox confirm输入文件样式在引导箱中不起作用确认
【发布时间】:2015-03-01 23:48:49
【问题描述】:

我的文件输入样式在我的整个网站中都能正常工作,除非我在 bootbox 中使用它。

引导箱代码:

function bootbox_file(att) {
bootbox.confirm("Add New Diagnosis Letter<form class='form-horizontal' enctype='multipart/form-data' id='infos' action='#' method='post'>\
        <br/>Upload File:  <input name='letter' id='id-input-file-2' type='file'>\
         \
        </form>", function(result) {
            if(result){
                       $('#infos').submit();
                   }
    });
}

jquery 文件代码:

$('#id-input-file-2').ace_file_input({
    no_file:'No File ...',
    btn_choose:'Choose',
    btn_change:'Change',
    droppable:false,
    onchange:null,
    thumbnail:false //| true | large
    //whitelist:'gif|png|jpg|jpeg'
    //blacklist:'exe|php'
    //onchange:''
    //
});

任何想法,谢谢。

【问题讨论】:

  • 需要在show 回调中初始化插件。您可能试图在元素存在之前进行初始化
  • 感谢评论,你能写一个简单的显示回调代码,因为我不知道在哪里初始化它。 @charlietfl
  • 在 boostrap 文档中,寻找模态的 show 回调。 bootbox 只是包装了引导 API

标签: jquery input styles bootbox


【解决方案1】:

感谢@charlietfl 的指导。

我编写了这段代码,它对我有用:

function bootbox_file() {
bootbox_confirm("<form class='form-horizontal' enctype='multipart/form-data' id='infos' action='#'>\
        <br/><input name='letter' type='file'>\
         \
        </form>", 'Upload', 'Cancel').modal('show');
}

function bootbox_confirm(msg, callback_success, callback_cancel) {
var d = bootbox.confirm({message:msg, title:"Upload New Letter", show:false, callback:function(result) {
    if (result)
        console.log("Hi ");
    else if(typeof(callback_cancel) == 'function')
        callback_cancel();
}});

d.bind('shown.bs.modal', function(){
    d.find("input:file").ace_file_input();
});
return d;
}

【讨论】:

    猜你喜欢
    • 2017-10-10
    • 1970-01-01
    • 1970-01-01
    • 2017-10-19
    • 2013-11-10
    • 1970-01-01
    • 2018-11-09
    • 2018-06-11
    • 2019-01-06
    相关资源
    最近更新 更多