浏览代码

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


部分文件因为文件数量过多而无法显示