开发者

connecting sortable lists disallowing sorting on the first list jQuery

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

I have 2 sortable lists th开发者_Go百科at 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.

Here is my code

$(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>

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.

Any ideas?


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜