连接可排序列表,不允许在第一个列表上排序jQuery [英] connecting sortable lists disallowing sorting on the first list jQuery

查看:66
本文介绍了连接可排序列表,不允许在第一个列表上排序jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这是否可行,但我想做些事情,

I don't know if this is possible but I want to do a few things,

我有2个可连接的可排序列表.我不想对第一个列表进行排序,但是我需要将这些项目拖到第二个列表中.

I have 2 sortable lists that are connected. I don't want to sort the first list, but I need the items to be able to be dragged into the 2nd list.

这是我的代码

$(document).ready(function() {
        $( "#webappsearchresults12267, #portfolio-ul" ).sortable({
            helper: 'clone',
            connectWith: ".connect",
            scroll: false,
            tolerance: 'intersect',
        stop: function(){
            var order = $("#portfolio-ul").sortable('toArray');
            $("#CAT_Custom_196863").val(order);
        }

        })
    });

<ul id="#webappsearchresults12267>
<li>item-1</li>
<li>item-2</li>
<li>item-3</li>
</ul>
<ul id="#portfolio-ul">
<li>item-4</li>
<li>item-5</li>
<li>item-6</li>
</ul>

我还有一个选项可以克隆我从第一个列表中拾取的项目... "helper:'clone'"似乎不适用于我,

I have also an option for cloning the item I pick up from the first list... "helper: 'clone'," doesn't appear to be working for me,

有人有什么想法吗?我可能不是在寻找可排序列表的解决方案,而是拖放第二个列表的可排序列表.

Anyone any ideas? I might not be looking at a sortable list solution but rather drag and drop.. with a sortable list for the 2nd list.

有什么想法吗?

推荐答案

首先,从HTML的ID中删除#",然后在调用"toArray"时使用LI项目的ID来获取一些数据.我发布了工作示例:

First of all, remove '#' from your IDs in HTML, next use IDs for LI items to get some data when 'toArray' called. I posted working example:

HTML:

<ul id="list1">
    <li id="ul_item_1">item-1</li>
    <li id="ul_item_2">item-2</li>
    <li id="ul_item_3">item-3</li>
</ul>
<br>
<br>
<ul id="list2">
    <li id="ul_item_4">item-4</li>
    <li id="ul_item_5">item-5</li>
    <li id="ul_item_6">item-6</li>
</ul>

JS

$( "#list1" ).sortable({
    helper: 'clone',
    connectWith: "#list2",
    scroll: false,
    tolerance: 'intersect',
stop: function(){
    var order = $("#list2").sortable('toArray');
    alert( order );
}

}).disableSelection();

$( "#list2" ).sortable().disableSelection();

http://jsfiddle.net/CoolEsh/4XAXR/3/

这篇关于连接可排序列表,不允许在第一个列表上排序jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆