1

我想在 jquery-file-upload API plugin 上添加一个自定义按钮。当所有文件上传时,此按钮处于启用状态,如果没有文件或没有上传文件,则按钮保持禁用状态。我想要一个按钮,所以当上传完成后,只有用户可以点击完成按钮,否则它保持禁用状态。

请帮忙 !!:(

4

1 回答 1

0

试试这个,在文件上传 html 中添加自定义按钮并使其禁用:

<div class="span7">
                    <span class="fileinput-button ufloat">
                        <span class="icon icon-plus"></span>
                        <span class="upload_txt">choose file to upload</span>
                        <input type="file" multiple="multiple" size="1"/>
                    </span>
                    <button type="submit" id="uploadBtn" class="btn-primary start">
                        <i class="icon icon-upload"></i>
                        <span>Upload</span>
                    </button>
                    <button type="reset" id="cancelBtn" class="btn-primary cancel">
                        <i class="icon icon-ban-circle"></i>
                        <span>cancel</span>
                    </button>

                    <!-- Adding your custom button -->
                    <button id="customBtn" disabled="true"></button>
                </div>

并在您的 main.js 中将其添加到您的完成功能中:

$('#fileuploadbasic').fileupload({
         done: function{
                  var filess= data.files[0];
            var filenam = filess.name;
            data.context.text('');
            $(data.context).append('<td class="name" colspan="6">'+filenam+' uploaded Success</td>');

// after finish upload and there are no other files to upload make
// make custom button enabled
if( $('tbody tr.template-upload td.start').length == 0) {
    $('#customBtn').removeAttr('disabled');
}
         }
});
于 2013-03-18T10:55:41.927 回答