ソースを参照

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


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません