views:

30

answers:

1

I have the following setup:

<ul class='_lscolumn'>
    <li>column1
        <ul class='_lswindow'>
            <li>window1
                <ul class='_lslink'>
                    <li>link1</li>
                    <li>link2</li>
                </ul>
            </li>
            <li>window2</li>
            <li>window3
                <ul class='_lslink'>
                    <li>link3</li>
                    <li>link4</li>
                </ul>
            </li>
        </ul>
    </li>
    <li>column2
        <ul class='_lswindow'>
            <li>window4</li>
        </ul>
    </li>
    <li>column3
        <ul class='_lswindow'>
            <li>window5</li>
            <li>window6</li>
        </ul>
    </li>
</ul>

What I want with this is be able to drag links to window classes, and windows to columns. Eventually I will add a tab, windows will need to be able to dragged to tabs as well. I'm trying to this using UI. I have a sample set up at www.linkshelf.com/jQuery/index.html. The window dragging works the way I want, but when I start to drag links the layout gets all wrong. Anybody knows what I'm doing wrong here, and what I need to do to be able to drag nested UL's?

If I make the columns sortable by adding $('_column').sortable(); the columns sort the way they should, but the windows and the links go bezerk...

+4  A: 

I worked on a JSFiddle for this, and what I found is that it can work as long as the target exists to drag to...

http://jsfiddle.net/gfosco/fJVMk/

See how this works, you can move the links around and they won't get out of order with the windows...

I added the UL and updated the class to have a min-height, otherwise there's nowhere to drop the links.

JS:

$('._lswindow').each( function() {
    $(this).sortable( {
        connectWith: '._lswindow',
        cancel: '._lslink'
    }).disableSelection();
});

$('._lslink').each( function() {
    $(this).sortable( {
        connectWith: '._lslink' }).disableSelection();
});

CSS addition:

._lslink {
 min-height:20px;   
}

HTML snippet of one window with empty link container:

    <ul class='_lswindow'> 
        <li>window4
            <ul class='_lslink'></ul>
        </li> 
    </ul>
Fosco
the problem is that I can't order the links in there, which is the same in your jsfiddle example... try ordering the links inside a couple of the windows. that's when the problem starts...
patrick
@patrick I am able to do that.. you're not?.. what browser?
Fosco
IE 8. When I grab 'link1' for instance 'window1', 'link2' and 'link2' are all moving around, but only 'link1' should be moving
patrick
works in Firefox indeed! So, we found a bug in UI when using IE?
patrick
@patrick Ahh... IE8, I see it now. Works awesome in Chrome. I will look and see if I can fix this for IE8.
Fosco
thanks! Should be something the UI guys should know about as well ;-)
patrick
I uploaded the code with your fixes, and added the dragging columns to it. Works fine in everything by IE. Maybe the link helps...
patrick
@patrick Check out the JSFiddle now. I added the cancel option to the window to not sort links (letting the link sorter handle that) and it works beautifully in IE now.)
Fosco
Yes, that fixed it! I'll dive into the manuals to know what's going. I really appreciate your help on this./
patrick