소스 검색

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

Kartik Visweswaran 10 년 전
부모
커밋
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


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.