代码之家  ›  专栏  ›  技术社区  ›  Pawan

如何获取select2 js的默认加载图标

  •  0
  • Pawan  · 技术社区  · 6 年前

    当在employee name文本字段中输入任意两个字符时,它将显示select2 js框架的默认加载程序。

    点击一个按钮,我们可以显示默认的加载器吗?是吗?

    我找不到与加载程序相关的类或ID。

    你能帮忙吗

    这是我的小提琴

    http://jsfiddle.net/XMAq2/1464/

    <div id="maincontainer" class="clearfix">
        <!-- main content s-->
        <div id="contentwrapper">
          <div class="main_content">
            <div class="row-fluid">
              <div class="span6" id="employeeColumn">
                <div class="control-group">
                  <label class="control-label">Employee Name: </label>
                  <div class="controls">
                    <input type="text" class="tags" id="select2_tags_id"/>                
                  </div>
                </div>
                <!--control group -->
              </div>
              <!-- Employee Column -->
    
            </div>
            <!-- row-fluid -->
          </div>
          <!-- main_content -->
        </div>
        <!-- content wrapper -->
      </div>
      <!-- End of maincontainer -->
    
    
    $(document).ready(function() {
        $('#select2_tags_id').select2({
            tokenSeparators: [','],
            tags: true,
            maximumSelectionSize: 10,
            minimumResultsForSearch: Infinity,
            multiple: true,
            dropdownCss: {
                display: 'none'
            }
        });
    
    
    });
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Charu Maheshwari    6 年前

    负责显示图标的样式是:

    .select2-container-multi .select2-choices .select2-search-field input.select2-active {
        background: #fff url(select2-spinner.gif) no-repeat 100% !important;
    }
    

    我不确定您要单击的按钮,但我的想法是,当您单击按钮时,需要在输入端添加类“select2 active”。 你可以检查小提琴 http://jsfiddle.net/XMAq2/1499/ “。”

    $( "#target" ).click(function() {
      alert('1');
        $('.select2-container-multi .select2-choices .select2-search-field input').addClass("select2-active");
    });
         <a class="btn btn-primary" id="target"> Click me <a/>