gpt4 book ai didi

javascript - Krajee Bootstrap 文件输入动态 maxFilecount

转载 作者:行者123 更新时间:2023-11-28 06:06:46 25 4
gpt4 key购买 nike

如果输入字段发生更改,我想使用动态数字设置 maxFileCount

我的代码:

<input value="" name="check_nums" class="check_nums">

krajee 文件输入:

$(document).on('ready', function() {
$('#file-th').fileinput({

var check_nums = $(".check_nums").val();

showUploadedThumbs: false,
language: 'th',
uploadAsync: false,
maxFileCount: [check_nums],
resizePreference: 'height',
resizeImage: true,
overwriteInitial: false,
validateInitialCount: true,
showUpload: false,

allowedFileExtensions: ['jpg', 'png', 'jpeg'],
previewSettings: {
image: {width: "auto", height: "100px"},
object: {width: "213px", height: "160px"},
},
layoutTemplates: {
actions: '<div class="file-actions">\n' +
' <div class="file-footer-buttons">\n' +
' {delete}' +
' </div>\n' +
'</div>',
}
}).on("filebatchselected", function(event, files) {

});
});

最佳答案

希望这会有所帮助:

首先更改变量声明位置,这是初始阶段声明的正确方法。

$(document).on('ready', function() {
var check_nums = $(".check_nums").val();
$('#file-th').fileinput({
showUploadedThumbs: false,
language: 'th',
uploadAsync: false,
maxFileCount: check_nums,
resizePreference: 'height',
resizeImage: true,
overwriteInitial: false,
validateInitialCount: true,
showUpload: false,
allowedFileExtensions: ['jpg', 'png', 'jpeg'],
previewSettings: {
image: {width: "auto", height: "100px"},
object: {width: "213px", height: "160px"},
},
layoutTemplates: {
actions: '<div class="file-actions">\n' +
' <div class="file-footer-buttons">\n' +
' {delete}' +
' </div>\n' +
'</div>',
}
}).on("filebatchselected", function(event, files) {

});
});

然后将更改事件与输入框绑定(bind),并将该输入值指定为文件输入的最大限制。

$(".check_nums").change(function(){
$("#file-th").fileinput('maxFileCount',$(this).val());
});

关于javascript - Krajee Bootstrap 文件输入动态 maxFilecount,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36784305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com