소스 검색

Fix #162: New property ajaxSettings to allow configuring ajax params

Kartik Visweswaran 10 년 전
부모
커밋
d3aacbfeb9
4개의 변경된 파일10개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 0
      CHANGE.md
  2. 3 0
      README.md
  3. 6 4
      js/fileinput.js
  4. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -16,6 +16,7 @@ version 4.1.7
        - `progressCompleteClass`: styling for progress bar when upload is complete
 9. (bug #159): Ensure filestack is passed correctly with `outData` for events.
 10. (bug #160): Correct documentation typo for usage.
+11. (enh #162): New property ajaxSettings to allow configuring ajax params.
 
 version 4.1.6
 =============

+ 3 - 0
README.md

@@ -894,6 +894,9 @@ _string_ markup for additional action buttons to display within the initial prev
 #### textEncoding
 _string_ the encoding to be used while reading a text file. Applicable only for previewing text files. Defaults to `UTF-8`. 
 
+#### ajaxSettings
+_object_ additional ajax settings to pass to the plugin before submitting the ajax request. Applicable only for ajax uploads. This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. Refer the [jQuery ajax documentation](http://api.jquery.com/jQuery.ajax/) for the various settings you can configure.
+
 ### Plugin Events
 The plugin supports these events:
 

+ 6 - 4
js/fileinput.js

@@ -957,9 +957,9 @@
             return xhrobj;
         },
         ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError) {
-            var self = this;
+            var self = this, settings;
             self.uploadExtra();
-            self.ajaxRequests.push($.ajax({
+            settings = $.extend(self.ajaxSettings, {
                 xhr: function () {
                     var xhrobj = $.ajaxSettings.xhr();
                     return self.initXhr(xhrobj, 98);
@@ -975,7 +975,8 @@
                 success: fnSuccess,
                 complete: fnComplete,
                 error: fnError
-            }));
+            });
+            self.ajaxRequests.push($.ajax(settings));
         },
         uploadSingle: function (i, files, allFiles) {
             var self = this, total = self.getFileStack().length, formdata = new FormData(), outData,
@@ -1757,7 +1758,8 @@
         dropZoneTitleClass: 'file-drop-zone-title',
         fileActionSettings: {},
         otherActionButtons: '',
-        textEncoding: 'UTF-8'
+        textEncoding: 'UTF-8',
+        ajaxSettings: {}
     };
 
     $.fn.fileinput.Constructor = FileInput;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
js/fileinput.min.js


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