views:

173

answers:

1

Hi!

I'm using YUI3 and I've been trying to make <tr> tags inside a table draggable with no luck. I've found that I can drag <div> nodes around, but for some reason I can't drag a <tr>. It shouldn't be a limitation, I've found examples of YUI2 where this is done, but the code is completely different from YUI3 and I can't figure this out.

Does anyone know if you can drag <tr> nodes in YUI3, and how to do this?

Here's my code:

YUI({combine: true, timeout: 10000}).use("dd-drop", "dd-constrain", "node", function (Y) {
    var drags = Y.Node.all('#draftable-players tr.drag');
    drags.each(function(v, k) {
        var dd = new Y.DD.Drag({
            node: v,
            dragMode: 'intersect'
        }).plug(Y.Plugin.DDConstrained, {
            constrain2node: '#draft'
       });
       dd.on('drag:end', function(e) {
           e.preventDefault();
       });
    });
});

And the relevant HTML:

<div id="draft">

<table id="draftable-players">
<tr class="drag"><td>some stuff</td></tr>
<tr class="drag"><td>some more stuff</td></tr>
</table>

<table> another table, i'm trying to drag <tr>s from the other one to this one
</table>

</div>

Any help would be appreciated. Thanks!

A: 

This question didn't garner too much interest, but I thought I'd answer it just as well in case someone comes across this in the future.

I found that you can't drag <tr> elements between two tables, only within the same table - further inspection of the YUI2 examples I mentioned above were doing exactly this, dragging within a given table.

I've since converted my tables to <div> elements and styled them to look like a <table> using CSS, and now I can drag from one 'table' to another. If anyone is curious to see some code for dragging and dropping, check out YUI3's docs here.

hora