فهرست منبع

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
 ## version 4.2.5
 
 
-**Date**: 22-Jul-2015
+**Date**: 27-Jul-2015
 
 
 1. (enh #362): Add Bulgarian translations.
 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
 ## 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
 #### 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:
 - `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).
     - `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) {
         ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError, previewId, index) {
             var self = this, settings;
             var self = this, settings;
+            self.raise('filepreajax', [previewId, index]);
+            self.uploadExtra(previewId, index);
             settings = $.extend({
             settings = $.extend({
                 xhr: function () {
                 xhr: function () {
                     var xhrobj = $.ajaxSettings.xhr();
                     var xhrobj = $.ajaxSettings.xhr();
@@ -1265,10 +1267,7 @@
                 cache: false,
                 cache: false,
                 processData: false,
                 processData: false,
                 contentType: false,
                 contentType: false,
-                beforeSend: function () {
-                    fnBefore.apply(this, arguments);
-                    self.uploadExtra(previewId, index);
-                },
+                beforeSend: fnBefore,
                 success: fnSuccess,
                 success: fnSuccess,
                 complete: fnComplete,
                 complete: fnComplete,
                 error: fnError
                 error: fnError

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
js/fileinput.min.js


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است