简体   繁体   English

实施多个组合框仅需一个下拉按钮

[英]Implementing multiple combo boxes results in only one drop down button

Using the code here : http://jqueryui.com/autocomplete/#combobox But replacing id with a class results in almost the desired functionality... except there is only drop down button for all combox box's. 在此处使用代码: http : //jqueryui.com/autocomplete/#combobox但是,用类替换id会产生几乎所需的功能...只是所有combox框只有一个下拉按钮。 How to get a drop down button for each combobox ? 如何获得每个组合框的下拉按钮?

<div class="ui-widget" style="display: inline-block;" >
  <select id="tag01" class="comboBox">
    <option value="">Select one...</option>
      <c:forEach items="${allTags}" var="tag">
        <option value="${tag.title}">${tag.title}</option>
      </c:forEach>
   </select>
</div>
<div class="ui-widget" style="display: inline-block;" >
  <select id="tag02" class="comboBox">
    <option value="">Select one...</option>
    <c:forEach items="${allTags}" var="tag">
      <option value="${tag.title}">${tag.title}</option>
    </c:forEach>
  </select>
</div>

and then calling comboxbox like so : 然后像这样调用comboxbox:

 $("#tag01").combobox();
 $("#tag02").combobox();

or 要么

 $(".comboBox").combobox();

results in only one drop down button. 结果只有一个下拉按钮。 Only if I remove display inline block from style of divs do I get multiple buttons, but then the combox boxs are on multiple lines - I do not want this. 仅当我从div样式中删除显示嵌入式块时,我才会获得多个按钮,但是combox框位于多行上-我不希望这样。

The drop down button is absolutely positioned, which means it does not impact the normal flow of the page. 下拉按钮的位置绝对正确,这意味着它不会影响页面的正常流程。 When you add the second combo box, the combination with position: relative in the container element leads to a box stacked on top of the button. 当您添加第二个组合框时,容器元素中与position: relative的组合将导致一个堆叠在按钮顶部的框。 Leaving some space on the right of the .ui-widget elements solves the problem. .ui-widget元素的右侧保留一些空间可以解决此问题。

For example, 例如,

<div class="ui-widget" style="display: inline-block; margin-right:40px">
  <select id="tag01" class="comboBox">
    ...
   </select>
</div>

See http://jsfiddle.net/YH3ep/3/ for a demo 有关演示,请参见http://jsfiddle.net/YH3ep/3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM