zoukankan      html  css  js  c++  java
  • select2搜索框查询加遍历

    <div class="form-group">
                        <label class="control-label col-sm-1 no-padding-right" for="entId">公司名称</label>
                        <div class="col-sm-10">
                            <div class="clearfix">
                                <select class="js-example-basic-single js-states form-control" name="entId" id="entId" style="100%">
                                    <option value="" _level="-1">--请选择--</option>
                                    <c:forEach items="${hjPztEntInfoList}" var="item">
                                        <option value="${item.value}">${item.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                    </div> 


    注意:jquery要在select2的上面
    <!-- JQuery script -->
    <!-- 非IE浏览器不会识别IE的条件注释,所以这里判断非IE需要如下写法:参照下面jquery-2.1.4.min.js引入的方式 -->
    <!--[if !IE]><!-->
    <script type="text/javascript" src="${ctx}/resources/js/plugins/jquery/jquery-2.1.4.min.js"></script>
    <!--<![endif]-->
    <!--[if IE]>
    <script type="text/javascript" src="${ctx}/resources/js/plugins/jquery/jquery-1.11.3.min.js"></script>
    <![endif]-->
    <script type="text/javascript" src="${ctx}/resources/js/plugins/select2/select2.min.js"></script>
    <script type="text/javascript" src="${ctx}/resources/js/plugins/select2/zh-CN.js"></script>
    <script src="${ctx}/resources/js/pzt/base/hjPztTalentInfo_Detail.js"></script>
    这里只有搜索框

    $(function(){ $("#entId").select2({ templateSelection : function(selection) { return $.trim(selection.text); } }); validateTalentInfoForm(); })
    这里是有加小图标的

    $(function(){ $("#entId").select2({ //templateResult : formatState, templateSelection : function(selection) { return $.trim(selection.text); } }); validateTalentInfoForm(); }) function formatState(state) { var $state = $('<span><i class="fa fa-file-text-o green"></i>&nbsp;&nbsp;' + state.text + '</span>'); return $state; }

     
  • 相关阅读:
    python--向钉钉群发送消息(亲测可用)
    python--注册钉钉回调事件(亲测可用)
    Gradle
    SpringBoot 中thymeleaf模板引擎的使用
    SpringBoot对静态资源的映射规则
    SpringBoot的日志使用
    rsync实现文件同步
    python学习: 优秀Python学习资源收集汇总--转
    Python高级特性: 12步轻松搞定Python装饰器
    Python常见问题
  • 原文地址:https://www.cnblogs.com/xuerong/p/5633147.html
Copyright © 2011-2022 走看看