Skip to content

Commit

Permalink
Fix #162: New property ajaxSettings to allow configuring ajax params
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Feb 5, 2015
1 parent e2ef8fc commit d3aacbf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
10 changes: 6 additions & 4 deletions js/fileinput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -1757,7 +1758,8 @@
dropZoneTitleClass: 'file-drop-zone-title',
fileActionSettings: {},
otherActionButtons: '',
textEncoding: 'UTF-8'
textEncoding: 'UTF-8',
ajaxSettings: {}
};

$.fn.fileinput.Constructor = FileInput;
Expand Down
4 changes: 2 additions & 2 deletions js/fileinput.min.js

Large diffs are not rendered by default.

0 comments on commit d3aacbf

Please sign in to comment.