【问题标题】:Jquery ui sortable array returning empty stringsJquery ui可排序数组返回空字符串
【发布时间】:2016-06-03 20:08:22
【问题描述】:

由于某种原因,jQuery UI 的 .sortable() 函数返回空字符串,我不知道为什么。这是我的代码:

<ul id="sortable">
    @{int i = 0;}
    @foreach (var item in Model.Columns)
    {
        if (item.isrequired == true)
        {
            <li class="col-lg-12 col-md-12 col-sm-12 ui-state-default">
                <span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
                <div class="col-lg-12 col-md-12 col-sm-12" style="position: relative;">
                    @Html.CheckBox("ColumnGroup", true, new { @value = item.column_name, @id = item.column_name, data_icon = "Foo_" + i, @name = "ColumnCheckbox", @disabled = "disabled", @class = "squaredThree" })&nbsp;
                    @Html.Label("", (string)item.column_name)&nbsp;&nbsp;
                    <span style="font-size: 0.9rem; color: red; vertical-align: text-top!important">*Required Column</span>
                </div>
            </li>
            i++;
        }
        else
        {
            <li class="col-lg-12 col-md-12 col-sm-12 ui-state-default">
                <span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
                <div class="col-lg-12 col-md-12 col-sm-12 checkAllBoxes" style="position: relative;">
                    @Html.CheckBox("ColumnGroup", true, new { @value = item.column_name, @id = item.column_name, data_icon = "Foo_" + i, @class = "squaredThree" })&nbsp;
                    @Html.Label("", (string)item.column_name)
                </div>
            </li>
            i++;
        }
    }
</ul>

和:

var sortedIDs = $( '#sortable' ).sortable( "toArray", { attribute: 'data-icon' } );

可拖动性很好,但我无法获得 li 的数组顺序

【问题讨论】:

  • 我看到 sortable 不是 selectable。你的 jQuery 代码在哪里?你有 jsfiddle.net 上的例子吗?
  • 我打错了标题。我的意思是输入可排序的。另外,我的 jQuery 代码在底部的帖子中。

标签: arrays jquery-ui razor html-helper


【解决方案1】:

我在 Li 元素上没有 ID,只有在输入上。一旦我将 id 添加到 lli 中,它就可以完美运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-07
    • 2011-02-18
    • 2012-06-05
    • 2013-12-19
    • 2012-04-20
    • 1970-01-01
    • 1970-01-01
    • 2016-05-28
    相关资源
    最近更新 更多