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

前端 未结 5 1904
被撕碎了的回忆
被撕碎了的回忆 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:29

    This didn't work for me.

    $('#fileupload').fileupload({url: '/url/to/server/'});
    
    $('#fileupload').bind('fileuploaddone', function (e, data) {
       console.log('success!!!');
    
       console.log(e);
    
       console.log(data);
    
    });
    

    But this did!

    $('#fileupload').fileupload({url: '/url/to/server/'}).bind('fileuploaddone', function (e, data) {
       console.log('success!!!');
    
       console.log(e);
    
       console.log(data);
    
    });
    

    My first guess is that in the first case you are binding the event to the actual form input instead of the fileupload object, and in the second, by using chainning you are actually using the fileupload object, I guess the documentation is ambiguous since it reads:

    $('#fileupload').bind('fileuploadadd', function (e, data) {/* ... */});
    

    And it should read

    $('#fileupload').fileupload().bind('fileuploadadd', function (e, data) {/* ... */});
    

提交回复
热议问题