Bootstrap fileinput layoutTemplates内 去掉缩略图下的上传按钮 及其他按钮或元素 也可重写指定元素 添加自定义图标等

本文主要是介绍Bootstrap fileinput layoutTemplates内 去掉缩略图下的上传按钮 及其他按钮或元素 也可重写指定元素 添加自定义图标等,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

参考  https://zhidao.baidu.com/question/2143865137819906308.html

 

上传小图标,用多文件同步上传的时候,有这个小图标操作的时候会出现各种情况,现在要把他们弄掉:

    

 

这里layoutTemplates为上传控件模板,可以在这里重写上传控件中的其他元素样式(空字符串表示无样式):

<script type="text/javascript">$(document).ready(function () {$("#fileinputId").fileinput({'theme': 'explorer-fas',	layoutTemplates :{//footer:'',//隐藏全部小图标;actionUpload:'',//去除上传预览缩略图中的上传图片;// indicator:'', //去除上传状态图标(左侧➕)// actionDrag:'',//去除拖动图标(通常编辑的时候会显示这个图标)//其他 参考fileinput.js/fileinput.min.js中 搜索 layoutTemplates,可以看到模板内所有元素  需要改哪个,直接在这里赋空字符串就行了},'uploadUrl': "file/uploadToServer",//后端文件上传URL,文件参数使用html中的input,对应name为fileuploadExtraData: {'a':'参数a','b':'参数b'},//后端文件上传URL相关参数(不包含附件)overwriteInitial: false,uploadAsync:false, //默认true 异步提交initialPreviewAsData: true,initialPreview: [// "http://demo.ruoyi.vip/img/profile.jpg",// "http://demo.ruoyi.vip/img/profile.jpg",]}).on('fileprepload', function(event, jsonData, previewId, index) {alert("异步单文件上传成功");}).on('filebatchuploadsuccess', function(event, jsonData, previewId, index) {alert("同步多文件上传成功");}).on('filebatchuploaderror', function(event, data, msg) {alert("上传失败");}).on("filepredelete",function (event,key) {return !confirm("确定删除?");});
});
</script>

 

------------------------------------------------------------

没去官网看文档,就直接自己顺着代码找一下吧:

上文js代码段中从$("#fileinputId").fileinput()  找到 layoutTemplates点进去fileinput.min.js源文件

文件是 xx.min.js 压缩文件,好,control+A 全文复制,网上找一个js解压网站,放入源码格式化一下,获得js代码(这里只展示layoutTemplates下代码);这里所有的key对应的值为动态生成的上传控件中的各元素样式

layoutTemplates: {main1: '{preview}\n<div class="kv-upload-progress kv-hidden"></div><div class="clearfix"></div>\n<div class="input-group {class}">\n  {caption}\n<div class="input-group-btn input-group-append">\n      {remove}\n      {cancel}\n      {upload}\n      {browse}\n    </div>\n</div>',main2: '{preview}\n<div class="kv-upload-progress kv-hidden"></div>\n<div class="clearfix"></div>\n{remove}\n{cancel}\n{upload}\n{browse}\n',preview: '<div class="file-preview {class}">\n    {close}    <div class="{dropClass}">\n    <div class="file-preview-thumbnails">\n    </div>\n    <div class="clearfix"></div>    <div class="file-preview-status text-center text-success"></div>\n    <div class="kv-fileinput-error"></div>\n    </div>\n</div>',close: i,fileIcon: '<i class="glyphicon glyphicon-file"></i>',caption: '<div class="file-caption form-control {class}" tabindex="500">\n  <span class="file-caption-icon"></span>\n  <input class="file-caption-name" onkeydown="return false;" onpaste="return false;">\n</div>',modalMain: a,modal: '<div class="modal-dialog modal-lg{rtl}" role="document">\n  <div class="modal-content">\n    <div class="modal-header">\n      <h5 class="modal-title">{heading}</h5>\n      <span class="kv-zoom-title"></span>\n      <div class="kv-zoom-actions">{toggleheader}{fullscreen}{borderless}{close}</div>\n    </div>\n    <div class="modal-body">\n      <div class="floating-buttons"></div>\n      <div class="kv-zoom-body file-zoom-content {zoomFrameClass}"></div>\n{prev} {next}\n    </div>\n  </div>\n</div>\n',progress: '<div class="progress">\n    <div class="{class}" role="progressbar" aria-valuenow="{percent}" aria-valuemin="0" aria-valuemax="100" style="width:{percent}%;">\n        {status}\n     </div>\n</div>',size: " <samp>({sizeText})</samp>",footer: '<div class="file-thumbnail-footer">\n    <div class="file-footer-caption" title="{caption}">\n        <div class="file-caption-info">{caption}</div>\n        <div class="file-size-info">{size}</div>\n    </div>\n    {progress}\n{indicator}\n{actions}\n</div>',indicator: '<div class="file-upload-indicator" title="{indicatorTitle}">{indicator}</div>',actions: '<div class="file-actions">\n    <div class="file-footer-buttons">\n        {download} {upload} {delete} {zoom} {other}    </div>\n</div>\n{drag}\n<div class="clearfix"></div>',actionDelete: '<button type="button" class="kv-file-remove {removeClass}" title="{removeTitle}" {dataUrl}{dataKey}>{removeIcon}</button>\n',actionUpload: '<button type="button" class="kv-file-upload {uploadClass}" title="{uploadTitle}">{uploadIcon}</button>',actionDownload: '<a class="kv-file-download {downloadClass}" title="{downloadTitle}" href="{downloadUrl}" download="{caption}" target="_blank">{downloadIcon}</a>',actionZoom: '<button type="button" class="kv-file-zoom {zoomClass}" title="{zoomTitle}">{zoomIcon}</button>',actionDrag: '<span class="file-drag-handle {dragClass}" title="{dragTitle}">{dragIcon}</span>',btnDefault: '<button type="{type}" tabindex="500" title="{title}" class="{css}" {status}>{icon} {label}</button>',btnLink: '<a href="{href}" tabindex="500" title="{title}" class="{css}" {status}>{icon} {label}</a>',btnBrowse: '<div tabindex="500" class="{css}" {status}>{icon} {label}</div>',zoomCache: '<div class="kv-zoom-cache" style="display:none">{zoomContent}</div>'
},

根据单词挨个匹配吧,这里只匹配了几个  其他的自行探索

main1
main2
preview
close
fileIcon
caption
modalMain
modal
progress
size
footer # 底部所有元素 (包含所有图标)
indicator #「➕图标」
actions
actionDelete # 「删除图标」
actionUpload #「上传图标」
actionDownload
actionZoom
actionDrag # 图片回显,编辑时候显示的「拖动图标」
btnDefault
btnLink
btnBrowse
zoomCache

------------------------------------------------------------

最快的方式就是,上传页面F12审查元素,指针点到对应元素,复制class名,到上面的js代码段里搜一下,对应的key放到页面js的layoutTemplates下就行了

 

layoutTemplates: {actionDelete: '',//去掉删除图标
},

 

------------------------------------------------------------

还可以自定义添加元素覆盖掉现有元素

layoutTemplates: {actionUpload: '<a>测试</a>',//重写上传按钮元素
},

 

 

 

 

 

这篇关于Bootstrap fileinput layoutTemplates内 去掉缩略图下的上传按钮 及其他按钮或元素 也可重写指定元素 添加自定义图标等的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/917650

相关文章

ROS话题通信流程自定义数据格式

ROS话题通信流程自定义数据格式 需求流程实现步骤定义msg文件编辑配置文件编译 在 ROS 通信协议中,数据载体是一个较为重要组成部分,ROS 中通过 std_msgs 封装了一些原生的数据类型,比如:String、Int32、Int64、Char、Bool、Empty… 但是,这些数据一般只包含一个 data 字段,结构的单一意味着功能上的局限性,当传输一些复杂的数据,比如:

SQL Server中,用Restore DataBase把数据库还原到指定的路径

restore database 数据库名 from disk='备份文件路径' with move '数据库文件名' to '数据库文件放置路径', move '日志文件名' to '日志文件存放置路径' Go 如: restore database EaseWe from disk='H:\EaseWe.bak' with move 'Ease

LeetCode--220 存在重复元素 III

题目 给定一个整数数组,判断数组中是否有两个不同的索引 i 和 j,使得 nums [i] 和 nums [j] 的差的绝对值最大为 t,并且 i 和 j 之间的差的绝对值最大为 ķ。 示例 示例 1:输入: nums = [1,2,3,1], k = 3, t = 0输出: true示例 2:输入: nums = [1,0,1,1], k = 1, t = 2输出: true示例

LeetCode--217 存在重复元素

题目 给定一个整数数组,判断是否存在重复元素。如果任何值在数组中出现至少两次,函数返回 true。如果数组中每个元素都不相同,则返回 false。 示例 示例 1:输入: [1,2,3,1]输出: true示例 2:输入: [1,2,3,4]输出: false示例 3:输入: [1,1,1,3,3,4,3,2,4,2]输出: true class Solution {p

FastAdmin/bootstrapTable 表格中生成的按钮设置成文字

公司有个系统后台框架用的是FastAdmin,后台表格的操作栏按钮只有图标,想要设置成文字。 查资料后发现其实很简单,主需要新增“text”属性即可,如下 buttons: [{name: 'acceptcompany',title: '复核企业',text:'复核企业',classname: 'btn btn-xs btn-primary btn-dialog',icon: 'fa fa-pe

添加自定义的CALayer

iOS开发UI篇—CAlayer(创建图层) 一、添加一个图层 添加图层的步骤: 1.创建layer 2.设置layer的属性(设置了颜色,bounds才能显示出来) 3.将layer添加到界面上(控制器view的layer上)  1 // 2 // YYViewController.m 3 // 01-创建一个简单的图层 4 // 5 //

XMG 重写- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event方法

//重写这个方法,来完成一些指定的事件。比如说按钮被遮到下面了,但是我想让点击到这块区域的时候让按钮去相应点击 - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {     // 当前坐标系上的点转换到按钮上的点     CGPoint btnP = [self convertPoint:point toVi

XMG xib中不属于一个类的控件,拖线到指定的类中

1.比如我现在有一个view绑定为GreenView,我们按住control向类里面拖线的方式想要达到目的,显然拖不进去。例图如下 那么我们此时还想要达到目的,就需要自己去GreenView的类内部去写IBo 然后这面连接起来 2.第二,大哥郝良建给做的扩展 可以在.h或者.m中写一个NSObject的属性 然后在xib中对应的位置创建一个NSObject的属性

MybatisPlus指定字段查询

一,上代码 QueryWrapper<Device> queryWrapper = Wrappers.query();queryWrapper.select("project_id as projectId,count(device_id) as total").in("project_id",projectIds).isNotNull("project_id").eq("del_flag",B

导航条下 ScrollView 第一个View去掉向下偏移的64px

self.automaticallyAdjustsScrollViewInsets=NO;      self.scrollView.contentInset=UIEdgeInsetsMake(-64, 0, 0, 0); self.automaticallyAdjustsScrollViewInsets=NO; 相同的意思。