0

I'm using Blueimp JQueryFileUpload from https://github.com/blueimp/jQuery-File-Upload

What I want is to set default options to the plugin, so I dont have to execute them everytime I use it, and in some specifics scenarios I will want to override my own default configurations.

I'm using the UI version of the plugin, and I want to set my own 'fileuploaddone' callback globally.

In some other plugins I achieve this throug

$.otherPlugin.options = { some : 'Default Options' }

2
  • Can you explain what specific options you want to set? Commented Jul 8, 2014 at 7:31
  • I want to set my own 'fileuploaddone' callback globally. Commented Jul 9, 2014 at 23:36

2 Answers 2

1

You can definitely add callback options. Read the documentation.

Here is what is did with my implementation. I added the code for callbacks in blueimp/js/main.js.

$('#fileupload').bind('fileuploadadd', function (e, data) {
    var fileList = $.trim($("#hdnFileList").val());

    if (fileList.length == 0) {
        $("#hdnFileList").val($.trim(data.files[0].name));
    } else {
        fileList = fileList + "," + $.trim(data.files[0].name);
        $("#hdnFileList").val(fileList);
    }
}).bind('fileuploaddone', function (e, data) {
    Add($("#hdnUploaded"), data.result.files[0].upFile);
    Add($("#hdnUploadedClientFile"), data.result.files[0].name);
});

Add being a custom function.

Sign up to request clarification or add additional context in comments.

Comments

0

A time after posting my question I finally found the solution in the documentation.

As described in the docs:

The recommended way to extend the jQuery File Upload plugin is by using the extension mechanism of the jQuery UI Widget Factory. This allows to override default Options (including callback methods) as well as methods of the File Upload widget class.

So, the following code can be used to override some default options

$.widget('blueimp.fileupload', $.blueimp.fileupload, {

    options: {
        autoUpload: false
    }
});

More informations can be foun at the official docs. https://github.com/blueimp/jQuery-File-Upload/wiki/Plugin-extensions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.