【问题标题】:how to call Sortable Event when sorting between the same list Jquery?在同一个列表Jquery之间排序时如何调用Sortable Event?
【发布时间】:2013-06-14 14:53:26
【问题描述】:

我有两个可排序的列表。当我将一个项目从 list1 排序到 list2 时,该功能有效,但是当我在同一个列表中排序时,该事件不起作用。

我正在使用接收事件,我将其更改为更新,但也没有用。

当我在同一个列表中更改项目的位置时,是否有任何功能被激活???

当我在同一个列表中排序时如何获取事件(更改同一个列表中项目的位置)??

  update : function(e, ui) { 
                 //alert('zone : ');
                           }

【问题讨论】:

  • 我发现该功能已停用,但我现在无法获取列表的发件人或收件人 ID,我是这样找到它们的:valuesender = ui.sender.attr('id'); valuereciever = $(this).attr('id');但是通过停用,我得到了与接收者相同的值。
  • 请发布完整的代码示例,如果可能,请在 jsFiddle.net 上发布示例。

标签: jquery


【解决方案1】:

您可以利用 sortableupdate 事件,如 JQuery UI API documentation 中所述,当排序发生在相同的列表。

$("#sortable").sortable({
    update : function(e, ui) {
        if (ui.sender == null && ui.item.parent().is($(this))) {
            // Items were sorted within the same list
            // Do something here...
        }
    }
});

【讨论】:

  • 据我所见,如果您将一个项目从 A 移到 B 中,则会在 B 上触发一个“更新”事件,并且 sender = null
【解决方案2】:

deactivate: function (event, ui) { yourFunction(event, ui, this); }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-20
    • 2011-05-05
    • 1970-01-01
    • 2021-02-03
    相关资源
    最近更新 更多