Browse Source

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

Kartik Visweswaran 9 năm trước cách đây
mục cha
commit
eff5d119fa
4 tập tin đã thay đổi với 19 bổ sung6 xóa
  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

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
js/fileinput.min.js


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác