Why doesn't Blueimp's jQuery-File-Upload plugin fire callbacks?

前端 未结 5 1871
被撕碎了的回忆
被撕碎了的回忆 2020-12-24 14:55

I\'m experimenting with Blueimp\'s jQuery-File-Upload plugin, which judging by the demo looks very promising.

It\'s really easy to implement:

var $up         


        
5条回答
  •  时光说笑
    2020-12-24 15:20

    I'm the author of the jQuery File Upload plugin.

    I don't have an explanation why the fileuploadadd event in your third example code doesn't fire. However, if you override the add callback option, you have to make sure the file upload is started by calling the submit method on the data argument, as explained in the Options documentation for the add callback (and also documented in the source code of the plugin).

    e.g. the following code should print out the different callback events:

    $('#fileupload').fileupload({
        add: function (e, data) {
            console.log('add');
            data.submit();
        },
        progress: function (e, data) {
            console.log('progress');
        },
        start: function (e) {
            console.log('start');
        }
    }).bind('fileuploadadd', function (e, data) {
        console.log('fileuploadadd');
    }).bind('fileuploadprogress', function (e, data) {
        console.log('fileuploadprogress');
    }).bind('fileuploadstart', function (e) {
        console.log('fileuploadstart');
    });
    

    Note also that the plugin is modular and the UI version (used in the download example) makes use of the callback options which would be overridden with the above code. That's why the event binding is so useful, as it allows to define additional callback methods without overriding the callbacks set via the options object.

提交回复
热议问题