多选不在ui内部工作:重复

时间:2016-12-20 07:18:47

标签: javascript jquery jsf bootstrap-multiselect

我正在尝试为ui:repeat中的每个条目实现多选框。 我尝试在document.ready和ui:repeat中初始化它。它仅应用于顶部第一行。

    <ui:repeat id="repeat" value="#{bean.list}" var="item" varStatus="status"><h:form id="supervisorCircleForm">
                                                                    <p:dataTable id="supervisor_table" var="pass"
                                                                                 value="#{bean.insideList}">
                                                                        <p:column headerText="Name" styleClass="center">
                                                                            <h:outputText value="#{pass.memberName}"/>
                                                                        </p:column>
                                                                        <p:column headerText="Companies"
                                                                                  styleClass="center">
                                                                            <select id="taxiCircle" multiple="multiple">
                                                                                <c:forEach var="item"
                                                                                           items="${bean.companyList}">
                                                                                    <option value="${item.value}">${item.label}</option>
                                                                                </c:forEach>
                                                                            </select>
<script type="text/javascript">
                                                                                            (function(){
                                                                                                $('#taxiCircle').multiselect();
                                                                                                console.log("Func Called");
                                                                                            })();
                                                                                        </script>                                                                        </p:column>
                                                                    </p:dataTable>
                                                                </h:form>
</ui:repeat>

每次调用初始化部分,但选择框仅出现一次。我试过在document.ready中调用它。 Multiselect coming only once

1 个答案:

答案 0 :(得分:0)

  1. recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity(), recyclerView, new SideMenuClickListener() { @Override public void onClick(View view, int position) { } @Override public void onLongClick(View view, int position) { } })); static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener { private GestureDetector gestureDetector; private SideMenuClickListener clickListener; public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final SideMenuClickListener clickListener) { this.clickListener = clickListener; gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return true; } @Override public void onLongPress(MotionEvent e) { View child = recyclerView.findChildViewUnder(e.getX(), e.getY()); if (child != null && clickListener != null) { clickListener.onLongClick(child, recyclerView.getChildPosition(child)); } } }); } @Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { View child = rv.findChildViewUnder(e.getX(), e.getY()); if (child != null && clickListener != null && gestureDetector.onTouchEvent(e)) { clickListener.onClick(child, rv.getChildPosition(child)); } return false; } @Override public void onTouchEvent(RecyclerView rv, MotionEvent e) { } @Override public void onRequestDisallowInterceptTouchEvent(boolean b) { } } 移除script代码,因为不需要重复,并在关闭ui:repeat后移动它。
  2. 您需要始终为元素使用唯一的body。如果没有,请改为id

    class