jquery-ui – 在droppable的Drop事件上调用$(item).sortable(‘cancel’)禁用可排序

我有一些可排序的连接列表,它们同时是可放置的地方.问题是,当我在droppable的drop事件中调用可排序的cancel方法时,sortable会被破坏而不再工作.示例 http://jsfiddle.net/zSnBA/10/尝试在第二个列表上移动div编号102:您将看到将调用cancel事件但是可以排序不再工作?有帮助吗?

解决方法

我建议不要使可排序列表也可以拖动,但是在sortable上听取receive事件来取消事件:
$('div.products-list').sortable({
    connectWith: '.products-list',placeholder: 'ui-state-highlight',items: 'div.product',revert: 200,receive: function(event,ui) {
        var prod_id = ui.item.attr("prod_id");

        /* Equal to 1 is valid because an item was just added to the list: */
        if ($(this).find(".product[prod_id='" + prod_id + "']").length > 1) {
            ui.sender.sortable("cancel");
        }
    }
});

示例:http://jsfiddle.net/z5X5y/

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...