javascript - 带有列表填充的 jQuery UI 可排序——不能超过数字

标签 javascript css jquery-ui jquery-ui-sortable

fiddle

html

<ol id="input-l8YFwLZvwNZ4" class="infinitext-lis">
    <li>
        <input type="text" name="answers[0[text]" style="width:275px" class="infinitext-text">
        <input type="hidden" name="answers[0][order]">
    </li>
    <li class="">
        <input type="text" name="answers[1[text]" style="width:275px" class="infinitext-text">
        <input type="hidden" name="answers[1][order]">
    </li>
    ...
</ol>

js

$('#input-l8YFwLZvwNZ4').sortable();

当您按编号捕获列表项之一并将其向上或向下拖动到其他列表编号之一上方时,它们不会移动并允许您将列表项放在那里。您必须拿起一个元素,将鼠标向右移动并将其放在其中一个文本框上。

有办法解决这个问题吗?

最佳答案

看看这个 fiddle :http://jsfiddle.net/k19o7adr/1/

可排序的有序列表存在一些问题,所以我将其更改为 ul 标签,现在一切正常。

$('#input2').sortable();
<ul id="input2" class="infinitext-lis">
    <li>1.
        <input type="text" name="answers[0[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[0][order]"/>
    </li>
    <li class="">2.
        <input type="text" name="answers[1[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[1][order]"/>
    </li>
    <li class="">3.
        <input type="text" name="answers[4[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[4][order]"/>
    </li>
    <li>4.
        <input type="text" name="answers[2[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[2][order]"/>
    </li>
    <li class="">5.
        <input type="text" name="answers[5[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[5][order]"/>
    </li>
    <li>6.
        <input type="text" name="answers[6[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[6][order]"/>
    </li>
    <li class="">7.
        <input type="text" name="answers[3[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[3][order]"/>
    </li>
    <li class="">8.
        <input type="text" name="answers[7[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[7][order]"/>
    </li>
    <li>9.
        <input type="text" name="answers[8[text]" style="width:275px" class="infinitext-text"/>
            <input type="hidden" name="answers[8][order]"/>
    </li>
</ul>

关于javascript - 带有列表填充的 jQuery UI 可排序——不能超过数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26434902/

相关文章:

javascript - 为什么这不是有效的正则表达式?

javascript - 如何防止我的程序在 setTimeout 之后继续运行?

javascript - 当用户单击外部图像时尝试更改标记的图标

css - 旋转对象上的底部填充动画如何导致 -DIAGONAL- 运动?

html - CSS 表格填充问题

javascript - 什么是溢出:overlay css property in mozilla and internet explorer browsers的替代品

javascript - onClick on commandLink 设置该链接所附图像的 css

javascript - 将所有 jquery ui-interaction-states 应用于所有 jquery ui-widget-content

javascript - jQuery AutoComplete 在第一次使用后显示在元素后面

javascript - 如何在循环中使用 jQuery UI 更新变量?