【问题标题】:Sortable elements move up when I select one for dragging当我选择一个进行拖动时,可排序元素向上移动
【发布时间】:2013-01-07 18:57:58
【问题描述】:

我正在使用 jQuery sortable 对多个 p:panels 进行排序。但是,当我选择要移动的任何元素时,其他元素会向上移动一个位置,这使得定位变得困难。我想完全按照jQueryUI Sortable 进行排序,其中元素仅在重叠时才会向上移动。有没有我可以使用的属性?

这是我的 jsf 代码:

<p:outputPanel id="dragPanel" styleClass="enumDiv">
    <ui:repeat value="#{numberEnumComponent.values}" var="numEnum"
        varStatus="values">
        <h:panelGrid columns="3" columnClasses="td-top,td-top,td-top"
            width="30%" style="padding-left: 10px;">

            <p:panel>
                <p:inputText value="#{numberEnumComponent.values[values.index]}"
                    id="numInput" binding="#{numInput}">
                    <f:converter converterId="javax.faces.BigDecimal"></f:converter>
                </p:inputText>
                <h:graphicImage value="#{msg.icon_type_NUMBER_ENUM}" id="enumIcon" style="padding-left:10px;"></h:graphicImage>

                <h:form id="removeForm" style="display:inline-block; padding-left:10px;">
                    <h:commandButton action="#{numberEnumComponent.removeNumEnum}"
                        image="#{numberEnumComponent.values.size() == 1 ? msg.icon_remove_disabled : msg.icon_remove}"
                        immediate="true"
                        disabled="#{numberEnumComponent.values.size() == 1}">
                        <f:setPropertyActionListener
                            target="#{numberEnumComponent.removePosition}"
                            value="#{values.index}"></f:setPropertyActionListener>
                    </h:commandButton>

                    <p:remoteCommand name="enumMovement" action="#{numberEnumComponent.columnMovement}">
                    </p:remoteCommand>
                </h:form>
            </p:panel>
        </h:panelGrid>
    </ui:repeat>
</p:outputPanel>

任何帮助将不胜感激!谢谢!

【问题讨论】:

    标签: jquery jquery-ui jsf jsf-2 jquery-ui-sortable


    【解决方案1】:

    使用drop placeholder 来防止其他元素移动可能会有所帮助。只需将其样式设置为与其他元素相同即可:

    $("#container").sortable({placeholder: '.placeholder'});
    

    【讨论】:

    • 试过了,不行!我根本没有占位符。
    • @Rajath by 试过了,你复制并粘贴我所做的,根本没有检查你的工作吗?或者您是否确保具有 .placeholder 类和 #container ID 的元素在您的上下文中确实有意义?
    • 我确实确保有一个 .placeholder 元素,我使用 &lt;style&gt; 标签指定了它的样式。
    • @Rajath 查看sortable 文档并尝试使用他们建议的任何占位符
    • 工作!我不得不删除&lt;h:panelGrid&gt;
    猜你喜欢
    • 2011-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多