我如何覆盖jquery fileupload插件选项

时间:2012-12-10 03:40:52

标签: jquery file-upload

我正在使用Jquery fileupload插件和Jquery UI

https://github.com/blueimp/jQuery-File-Upload/wiki/Options

我想覆盖像maxUploadfilesize

这样的小部件选项

如果我覆盖主文件jquery.fileupload-ui.js

中的设置,则为当前

然后它起作用

var parentWidget = ($.blueimpFP || $.blueimp).fileupload;
    $.widget('blueimpUI.fileupload', parentWidget, {

        options: {
            // By default, files added to the widget are uploaded as soon
            // as the user clicks on the start buttons. To enable automatic
            // uploads, set the following option to true:
            autoUpload: true,
            //sequentialUploads, true,
            // The following option limits the number of files that are
            // allowed to be uploaded using this widget:
            maxNumberOfFiles: undefined,
            // The maximum allowed file size:
            maxFileSize: 20000000,
            // The minimum allowed file size:
            minFileSize: undefined,

有什么方法可以在我的html模板中覆盖它,以便我可以为不同的html页面进行不同的自定义

我的意思是一些javvscript代码,我可以把它放在模板中,覆盖默认设置

1 个答案:

答案 0 :(得分:3)

他们的documentation表示您可以覆盖它们

只需将此代码放在初始化插件

的位置即可
$('#fileupload').fileupload(
    'option',
    {
        maxFileSize: 4000000,
        sequentialUploads: true
    }
);