【问题标题】:jQuery UI sortable w/ list padding -- cannot drop over numberjQuery UI 可排序 w/ 列表填充 - 不能丢弃数字
【发布时间】:2014-10-17 23:46:25
【问题描述】:

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();

当您按编号抓取其中一个列表项并将其向上或向下拖动到其他列表编号之一的顶部时,它们不会移动并允许您将列表项放在那里。您必须拿起一个项目,将鼠标向右移动,然后将其放在其中一个文本框上。

有没有办法解决这个问题?

【问题讨论】:

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


【解决方案1】:

看看这个小提琴: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>

【讨论】:

  • 这并没有真正改变任何东西。通过项目符号而不是数字来获取列表项——它有完全相同的问题。您可以通过数字抓取元素的原因是您已将它们移动到列表项中。
猜你喜欢
  • 2022-11-11
  • 2012-08-05
  • 1970-01-01
  • 1970-01-01
  • 2012-05-29
  • 1970-01-01
  • 1970-01-01
  • 2016-11-27
  • 2011-11-12
相关资源
最近更新 更多