浏览代码

Better fix for upload extra data fixes #370 & fixes #372

Kartik Visweswaran 9 年之前
父节点
当前提交
eff5d119fa
共有 4 个文件被更改,包括 19 次插入6 次删除
  1. 3 1
      CHANGE.md
  2. 13 1
      README.md
  3. 3 4
      js/fileinput.js
  4. 0 0
      js/fileinput.min.js

+ 3 - 1
CHANGE.md

@@ -3,9 +3,11 @@ Change Log: `bootstrap-fileinput`
 
 ## version 4.2.5
 
-**Date**: 22-Jul-2015
+**Date**: 27-Jul-2015
 
 1. (enh #362): Add Bulgarian translations.
+2. (bug #370): Reverts #342 with better fix.
+3. (enh #372): Create new event `filepreajax`.
 
 ## version 4.2.4
 

+ 13 - 1
README.md

@@ -1269,8 +1269,20 @@ $('#input-id').on('fileunlock', function(event, filestack) {
 });
 ```
 
+#### filepreajax
+This event is triggered before submission of the upload ajax request. You could use this event to manipulate the uploadExtraData before its submitted via ajax. The following additional parameters are also available but only if the upload is triggered via each thumbnail upload button.
+
+- `previewId`: the identifier of the preview thumbnail container.
+- `index`: the zero-based index of the file in the preview container.
+
+```js
+$('#input-id').on('filepreajax', function(event, previewId, index) {
+    console.log('File pre ajax triggered');
+});
+```
+
 #### filepreupload
-This event is triggered before upload of each thumbnail file. Additional parameters available are: 
+This event is triggered before upload of each thumbnail file. This event is triggered after `filepreajax` and within the ajax `beforeSend`. Additional parameters available are: 
 
 - `data`: This is a data object (associative array) that sends the following information, whose keys are:
     - `form`: the FormData object which is passed via XHR2 (or empty object if not available).

+ 3 - 4
js/fileinput.js

@@ -1253,6 +1253,8 @@
         },
         ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError, previewId, index) {
             var self = this, settings;
+            self.raise('filepreajax', [previewId, index]);
+            self.uploadExtra(previewId, index);
             settings = $.extend({
                 xhr: function () {
                     var xhrobj = $.ajaxSettings.xhr();
@@ -1265,10 +1267,7 @@
                 cache: false,
                 processData: false,
                 contentType: false,
-                beforeSend: function () {
-                    fnBefore.apply(this, arguments);
-                    self.uploadExtra(previewId, index);
-                },
+                beforeSend: fnBefore,
                 success: fnSuccess,
                 complete: fnComplete,
                 error: fnError

文件差异内容过多而无法显示
+ 0 - 0
js/fileinput.min.js


部分文件因为文件数量过多而无法显示