At first I didn't find a way to make an element take up new child
elements, i.e. a way to make item2 (sibling of item1) go "under" item1

Then I inserted a "faux" UL inside every LI under the tree element (do
this before you start the sortable). Since this didn't work, I had to
make an empty LI inside every faux UL. Set some on-the-fly CSS (height
of the faux LI has to be more than 1px, otherwise it's hard to hit the
right spot) and you have yourself a LI that accepts new items to it's
hidden UL.

here's the complete function:

//// CREATE SORTABLE TREE LIST WHICH ACCEPTS NEW CHILD ELEMENTS

function sortableTreeAdvanced(element){

        element = $(element);
        element.select('li').each( // this is each LI recursive
        function (li){
                if (!li.down('ul')){ // make sure that an child UL does not 
already
exist
                        /// now let's create a faux UL, which is more-
or-less hidden, so it can accept new mushrooms
                        var fauxUL=document.createElement('ul');
                        var fauxLI=document.createElement('li');
                        fauxLI.style.height = '3px';
                        fauxLI.style.listStyleType = 'none';
                        fauxUL.appendChild(fauxLI);

                        li.appendChild(fauxUL); // put the hidden list inside 
the LI
                }
        }); /// end each LI

        Sortable.create(element, { tree:true, treeTag:'ul'} );

}

sortableTreeAdvanced('sortable_test');
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to