Skip to content

Commit eff5d11

Browse files
committed
Better fix for upload extra data fixes #370 & fixes #372
1 parent e60f20b commit eff5d11

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

CHANGE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ Change Log: `bootstrap-fileinput`
33

44
## version 4.2.5
55

6-
**Date**: 22-Jul-2015
6+
**Date**: 27-Jul-2015
77

88
1. (enh #362): Add Bulgarian translations.
9+
2. (bug #370): Reverts #342 with better fix.
10+
3. (enh #372): Create new event `filepreajax`.
911

1012
## version 4.2.4
1113

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,8 +1269,20 @@ $('#input-id').on('fileunlock', function(event, filestack) {
12691269
});
12701270
```
12711271

1272+
#### filepreajax
1273+
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.
1274+
1275+
- `previewId`: the identifier of the preview thumbnail container.
1276+
- `index`: the zero-based index of the file in the preview container.
1277+
1278+
```js
1279+
$('#input-id').on('filepreajax', function(event, previewId, index) {
1280+
console.log('File pre ajax triggered');
1281+
});
1282+
```
1283+
12721284
#### filepreupload
1273-
This event is triggered before upload of each thumbnail file. Additional parameters available are:
1285+
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:
12741286

12751287
- `data`: This is a data object (associative array) that sends the following information, whose keys are:
12761288
- `form`: the FormData object which is passed via XHR2 (or empty object if not available).

js/fileinput.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,8 @@
12531253
},
12541254
ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError, previewId, index) {
12551255
var self = this, settings;
1256+
self.raise('filepreajax', [previewId, index]);
1257+
self.uploadExtra(previewId, index);
12561258
settings = $.extend({
12571259
xhr: function () {
12581260
var xhrobj = $.ajaxSettings.xhr();
@@ -1265,10 +1267,7 @@
12651267
cache: false,
12661268
processData: false,
12671269
contentType: false,
1268-
beforeSend: function () {
1269-
fnBefore.apply(this, arguments);
1270-
self.uploadExtra(previewId, index);
1271-
},
1270+
beforeSend: fnBefore,
12721271
success: fnSuccess,
12731272
complete: fnComplete,
12741273
error: fnError

js/fileinput.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)