2014-04-04 83 views
2

我使用dropzonejs這樣:懸浮窗行動被上傳

<script type="text/javascript"> 
     jQuery(function($) { 
      try 
      { 
       $(".dropzone").dropzone({ 
        paramName: "file", // The name that will be used to transfer the file 
        maxFilesize: 0.5, // MB 
        uploadMultiple: true, 
        //addRemoveLinks : true, 
        dictDefaultMessage : 
         '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> Drop files</span> to upload \ 
         <span class="smaller-80 grey">(or click)</span> <br /> \ 
         <i class="upload-icon icon-cloud-upload blue icon-3x"></i>', 
        dictResponseError: 'Error while uploading file!',    
        //change the previewTemplate to use Bootstrap progress bars 
        previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"progress progress-small progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n <div class=\"dz-success-mark\"><span></span></div>\n <div class=\"dz-error-mark\"><span></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>" 
       }); 
      } 
      catch(e) 
      { 
       alert('Dropzone.js does not support older browsers!'); 
      } 
}); 

    </script> 

確切位置在哪裏我可以把聽衆做做某事(重載/重定向/警報)的所有文件都上傳後?

回答

1

您需要參數completemultiple,該參數是一旦所有文件上傳完成後都會調用的函數。

而且FO感興趣的你:

  • processingmultiple
  • sendingmultiple
  • successmultiple
  • canceledmultiple

來源:http://www.dropzonejs.com/

+0

你能舉個例子嗎?我想這樣,但它不工作: 初始化:函數(){ \t \t \t \t \t this.on( 「completemultiple」 功能(文件){警報( 「添加文件」);}); \t \t \t \t \t}, – user3174311

+0

所以你沒有看到警報?你可以檢查以確保你有最新的dropzone JS?沿着'paramName'等其他dropzone參數添加completemultiple參數。 – Scott

4

下面是使用jQuery通用的初始化腳本懸浮窗

Dropzone.options.myDropZoneForm = { 
    url: 'url/here', 
    autoProcessQueue: false, 
    uploadMultiple: true, 
    parallelUploads: 100,  
    addRemoveLinks: true, 
    uploadMultiple: true, 
    acceptedFiles: 'image/*, audio/*, video/*', 
    maxFiles: 10, 
    init: function() { 
     var thisDropzone = this; 

     // just showing some dropped files stats 
     var totalFiles = 0, completeFiles = 0; 
     this.on('addedfile', function(file){ 
      totalFiles += 1; 
      totalFilesFormatted = totalFiles.toFixed(2); 
      $('#showTotalFileCount').html(totalFilesFormatted); 
     }); 
     this.on('removedfile', function(file){ 
      totalFiles -= 1; 
      totalFilesFormatted = totalFiles.toFixed(2); 
      $('#showTotalFileCount').html(totalFilesFormatted); 
     }); 
     this.on('maxfilesreached', function(file){ 
      alert('maxFiles reached'); 
     }); 
     this.on('maxfilesexceeded', function(file){ 
      alert('files dropped exceeded maxFiles'); 
     }); 
     this.on("sendingmultiple", function(){ 
      // event when files are being sent 
     }); 
     this.on("successmultiple", function(files, response) { 
      // event when files are successfully uploaded 
      // you can return a response string and process it here through 'response' 
     }); 
     this.on("errormultiple", function(files, response) { 
      // event when there's an error 
     }); 
    } 
} 

希望這有助於你化解的東西。乾杯!