Select2 多选框

news/2024/7/19 15:50:35 标签: select2, js, select


1. 引入select,官网可以下载

<link rel="stylesheet" href="$!static/static/js/select2>select2-4.0.3/select2>select2.min.css"/>
<script src="$!static/static/js/select2>select2-4.0.3/select2>select2.js"></script>
<script src="$!static/static/js/select2>select2-4.0.3/zh-CN.js"></script>

2. 页面使用,select标签,本人用的velocity

<select class="select-multiple" multiple="multiple" name="cateId">
                            #foreach($bdoPO in $cateList)
                                <option value="$bdoPO.id">$bdoPO.cateName</option>
                            #end
                        </select>


3 . 页面加载select2>select2

$(".select-multiple").select2>select2();

或者根据name渲染:

$('select[name=route]').select2>select2({
        placeholder: "选择航线",
        allowClear: true
    });


4.  根据name正常提交表单即可,选择多个的场合值逗号分隔


5. 回显,通过数组回显

var arr = '$!line.cateId'.split(",");
$('#gl select[name=cateId]').select2>select2("val", [arr]);





http://www.niftyadmin.cn/n/1332776.html

相关文章

URL下载文件服务器文件

前台页面请求&#xff1a; window.location.href "/download/download?fileUrl" data.contractUrl "&originName" data.originName;后台下载处理&#xff1a; import com.alibaba.dubbo.common.utils.StringUtils; import org.slf4j.Logger; impo…

重写toString方法-日志

在项目中会使用log4j来记录日志&#xff0c;例如外围系统传参数过来(这里特指对象)&#xff0c; 线上环境调查问题的时候查日志&#xff0c;就需要知道到底传过来的每个值是什么&#xff0c; 那么就会有以下的写法&#xff1a; if (LOGGER.isDebugEnabled()) {LOGGER.debug(&…

Netty/NIO 概念

何为非阻塞&#xff1f; 下面有个隐喻&#xff1a; 一辆从 A 开往 B 的公共汽车上&#xff0c;路上有很多点可能会有人下车。司机不知道哪些点会有哪些人会下车&#xff0c;对于需要下车的人&#xff0c;如何处理更好&#xff1f; 1. 司机过程中定时询问每个乘客是否到达目的地…

velocity判断空和null

判断是否为null有下面几种方法&#xff1a; 1. #if (! $foo) 判断$foo为空&#xff0c;判断非空为 #if ($foo) 2. 使用 #ifnull() 或 #ifnotnull() #ifnull ($foo) 要使用这个特性必须在velocity.properties文件中加入&#xff1a; userdirective org.apache.velocity.tools.…

单点登录没跳转到登录页面

场景&#xff1a;单点登录 A系统与B系统登录成功&#xff0c;然后A系统退出&#xff0c;点击B系统菜单或操作按钮&#xff1a; 预期&#xff1a;跳转到登录页面&#xff0c;让用户登录 实际&#xff1a;无反应&#xff0c;查看js报500 内部网络错误 直接刷新页面可以跳转到登…

Velocity FieldTool

网上资料太乱&#xff0c;项目中使用到了就特此整理一下&#xff1a; 1 . velocity 版本&#xff1a;velocity-tools:2.0 <dependency><groupId>org.apache.velocity</groupId><artifactId>velocity</artifactId><version>1.7</version…

Netty/NIO实践

Netty的异步事件驱动模型主要涉及到下面几个核心的概念&#xff1a;Channel&#xff1a;表示一个与socket关联的通道ChannelPipeline&#xff1a; 管道&#xff0c;一个Channel拥有一个ChannelPipeline&#xff0c;ChannelPipeline维护着一个处理链&#xff08;严格的说是两 个…

利用fastjson和反射实现为VO属性赋值

应用场景&#xff1a; 外围系统发来的请求&#xff0c;传递的json形式的string数据&#xff0c;即服务端要解析&#xff0c;落地&#xff01;&#xff01;&#xff01; package com.xx.epay.portal.converter;import com.alibaba.fastjson.JSON; import com.xx.xx.xx.pojo.Pay…