开发者

drag and drop - sortable not working when list comes dynamically

开发者 https://www.devze.com 2023-03-22 11:30 出处:网络
Here i have done : http://jsfiddle.net/thilakar/QNkEL/2/ I can draggable the parent element and child element too. but i need drop the content between the child and another child(another parent c开发

Here i have done : http://jsfiddle.net/thilakar/QNkEL/2/

I can draggable the parent element and child element too. but i need drop the content between the child and another child(another parent c开发者_StackOverflowhild element.)

My requirement:

i need to drag and drop the text between child and also drop the content another parent child.

My Problem:

sortable not working when list comes dynamically.

Please help me..

thanks


I changed your javascript a little and i think i'm close to what you need:

$(document).ready(function() {
    var treeList = "";
    var listTree = 0;
    var innerTree = 0;

    treeList = "<ul id=\"createTree\" class=\"droptrue\">";
    for (var key in jsonObj) {
        //alert("key: " + key + ", value: " + jsonObj[key])
        for (var skey in jsonObj[key]) {
            treeList += ("<li class=\"listTree\" id=\"asdf\">" + skey + "<ul id=\""+skey+"\">");
            for (var sskey in jsonObj[key][skey]) {
                for (var ssskey in jsonObj[key][skey][sskey]) {
                    treeList += ("<li class=\"innerList\">" + jsonObj[key][skey][sskey][ssskey] + "</li>");
                }
            }
            treeList += "</ul></li>";
        }
    }
    treeList += "</ul>";

    $('#tree').append(treeList);


    $(".listTree ul").sortable({
        revert: true
    });


    $("#Title1 li").draggable({
        helper: "clone",
        cursor: 'hand',
        revert: 'invalid',
        connectToSortable: "#Title2",
    });

        $("#Title2 li").draggable({
        helper: "clone",
        cursor: 'hand',
        revert: 'invalid',
        connectToSortable: "#Title1",
    });
    $( "ul, li" ).disableSelection();

});

fiddle here: http://jsfiddle.net/nicolapeluchetti/QNkEL/6/

0

精彩评论

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