Skip to content

Commit 333da5e

Browse files
committed
Fix #1480: Correct preview content setting after validation error
1 parent ee58364 commit 333da5e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

CHANGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Change Log: `bootstrap-fileinput`
2727
- (bug #1499, #1502): Correct duplicate file check error rendering.
2828
- (enh #1497): Better validation of progress display when `showPreview` is `false`.
2929
- (bug #1482): Validate `initialPreviewShowDelete` setting correctly.
30+
- (bug #1480): Correct preview content setting after validation error.
3031

3132
## version 5.0.7
3233

js/fileinput.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@
17751775
if (!$h.isArray(content)) {
17761776
content = content.split(self.initialPreviewDelimiter);
17771777
}
1778-
if (append) {
1778+
if (append && data.content && data.content.length) {
17791779
index = data.content.push(content[0]) - 1;
17801780
data.config[index] = config;
17811781
data.tags[index] = tags;
@@ -2057,7 +2057,12 @@
20572057
var self = this, label = self.minFileCount > 1 ? self.filePlural : self.fileSingle,
20582058
msg = self.msgFilesTooLess.replace('{n}', self.minFileCount).replace('{files}', label),
20592059
$error = self.$errorContainer;
2060-
self._addError(msg);
2060+
msg = '<li>' + msg + '</li>';
2061+
if ($error.find('ul').length === 0) {
2062+
self._addError('<ul>' + msg + '</ul>');
2063+
} else {
2064+
$error.find('ul').append(msg);
2065+
}
20612066
self.isError = true;
20622067
self._updateFileDetails(0);
20632068
$error.fadeIn(self.fadeDelay);
@@ -4868,7 +4873,7 @@
48684873
}
48694874
if (self.isAjaxUpload) {
48704875
self._raise('filebatchselected', [fm.stack]);
4871-
if (fm.count() === 0) {
4876+
if (fm.count() === 0 && !self.isError) {
48724877
self.reset();
48734878
}
48744879
} else {

0 commit comments

Comments
 (0)