刷新可拖动/可放置

时间:2011-09-25 16:23:33

标签: javascript jquery draggable droppable

我有可拖动/可丢弃的树,用户可以在其中添加新元素。用户单击“添加”按钮后,新元素将添加到树中。如何在新添加的元素上刷新树,可拖动和dropabble:

            $("li.tree_item a").droppable({
            tolerance        : "pointer",
            hoverClass        : "tree_hover",
            drop            : function(event, ui){
                var dropped = ui.draggable;
                dropped.css({top: 0, left: 0});
                var me = $(this).parent();
                if(me == dropped)
                    return;
                var subbranch = $(me).children("ul");
                if(subbranch.size() == 0) {
                    me.find("a").after("<ul></ul>");
                    subbranch = me.find("ul");
                }
                var oldParent = dropped.parent();
                subbranch.eq(0).append(dropped);
                var oldBranches = $("li", oldParent);
                if (oldBranches.size() == 0) { $(oldParent).remove(); }

                var data = Object();
                    data.tree = Array();
                    data.tree = parseTree($("#tag_tree"));

                $.getJSON( urlJson, data, function(resp) {      
                }); 

            }
        });

        $("li.tree_item").draggable({
            opacity: 0.5,
            revert: true,
        });

和向该树添加元素的按钮

        $('#add').bind('click', function() {


        });

如何在添加新元素后刷新可拖动的droppable?

0 个答案:

没有答案