浏览代码

Fix #1079: Correct initial preview rendering when no `initialPreviewConfig` supplied

Kartik Visweswaran 7 年之前
父节点
当前提交
94a5337c12
共有 3 个文件被更改,包括 6 次插入2 次删除
  1. 1 0
      CHANGE.md
  2. 5 2
      js/fileinput.js
  3. 0 0
      js/fileinput.min.js

+ 1 - 0
CHANGE.md

@@ -7,6 +7,7 @@ Change Log: `bootstrap-fileinput`
 
 **_This release adds Bootstrap v4.x support._**
 
+- (bug #1079): Correct initial preview rendering when no `initialPreviewConfig` supplied.
 - (enh #1078): Correct markup during file validation errors (non-ajax mode).
 - (enh #1075): Enhance initial preview delete behavior (ensure `previewCache` splices deleted initial preview content items).
 - (enh #1073): Enhance `refresh` method to overwrite options.

+ 5 - 2
js/fileinput.js

@@ -899,10 +899,13 @@
                     return {content: html, caption: caption};
                 },
                 footer: function (i, isDisabled, size) {
-                    var data = self.previewCache.data;
-                    if (!data || !data.config || data.config.length === 0 || $h.isEmpty(data.config[i])) {
+                    var data = self.previewCache.data || {};
+                    if ($h.isEmpty(data.content)) {
                         return '';
                     }
+                    if ($h.isEmpty(data.config) || $h.isEmpty(data.config[i])) {
+                        data.config[i] = {};
+                    }
                     isDisabled = isDisabled === undefined ? true : isDisabled;
                     var config = data.config[i], caption = $h.ifSet('caption', config), a,
                         width = $h.ifSet('width', config, 'auto'), url = $h.ifSet('url', config, false),

文件差异内容过多而无法显示
+ 0 - 0
js/fileinput.min.js


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