Problem with tables, $getChildren searches only immediate descendants #20

Closed
slamarca opened this Issue May 22, 2013 · 3 comments

Projects

None yet

2 participants

@slamarca

Hi, I downloaded version 0.9.9 to use in my site. First of all, thanks for the good work!

Now, on to the problem. I used your plugin to setup a sortable table using the example (table.js), but the insertion pointer didn't work properly, going always to the end of the table. Lurking in the code I found that in getItemDimensions function the $getChildren call returned an empty array. It seems to me that when you have a table-tbody-tr .... arrangement $getChildren tries to get 'tr' elements immediately under the 'table' element (as pointed to by the 'el' property in the first argument to the function). In the plugin setup (as indicated by the example) I set the 'containerSelector' option to a 'tbody' tag, so I substituted this.option.containerSelector to this.el as first argument to $getChildren and now all works like a charm!

It's ok for my needs, surely you will investigate better into this issue (if you think this is the case).

Thanks again,
Sergio La Marca
Italy

PS: Maybe a duplicate issue? I read the closed issues after writing this message :(

Owner
johnny commented Jun 25, 2013

Sorry for taking so long to respond. The reason is I have not answered can be partly explained that I have no easy solution to this. Your approach would fail, if there is another table nested inside. Then you would get the grandchildren also.

I have not yet found a general solution which would work with arbitrarily nested containers. I will leave this open as a reminder.

BTW, if you call $('tbody').sortable, as in this example http://johnny.github.io/jquery-sortable/#table your case should work out of the box

Thanks anyway.

Sergio

2013/6/25 Jonas von Andrian notifications@github.com

Sorry for taking so long to respond. The reason is I have not answered can
be partly explained that I have no easy solution to this. Your approach
would fail, if there is another table nested inside. Then you would get the
grandchildren also.

I have not yet found a general solution which would work with arbitrarily
nested containers. I will leave this open as a reminder.

BTW, if you call $('tbody').sortable, as in this example
http://johnny.github.io/jquery-sortable/#table your case should work out
of the box


Reply to this email directly or view it on GitHubhttps://github.com/johnny/jquery-sortable/issues/20#issuecomment-20001030
.

@johnny johnny added a commit that closed this issue Jul 15, 2013
@johnny added new options: (container|item)Path
closes #20
6936bb4
@johnny johnny closed this in 6936bb4 Jul 15, 2013
Owner
johnny commented Jul 15, 2013

I added a new option itemPath which deals with these kinds of problems. See the table example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment