Skip to content

Commit 6936bb4

Browse files
committed
added new options: (container|item)Path
closes johnny#20
1 parent 38ebf09 commit 6936bb4

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

source/_table.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
%p= show_code_button
2020
.span4
2121
%h3 Sortable Rows
22-
%table.table.table-striped.table-bordered
22+
%table.table.table-striped.table-bordered.sorted_table
2323
%thead
2424
%tr
2525
%th A Column
2626
%th B Column
27-
%tbody.sorted_table
27+
%tbody
2828
= iterate(6) do |i, name|
2929
%tr
3030
%td A #{name}

source/js/examples/table.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
$(function () {
22
// Sortable rows
33
$('.sorted_table').sortable({
4-
containerSelector: 'tbody',
4+
containerSelector: 'table',
5+
itemPath: '> tbody',
56
itemSelector: 'tr',
67
placeholder: '<tr class="placeholder"/>'
78
})

source/js/jquery-sortable.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@
4747
// This is executed after the placeholder has been moved.
4848
afterMove: function ($placeholder, container) {
4949
},
50+
// The exact css path between the container and its items, e.g. "> tbody"
51+
containerPath: "",
5052
// The css selector of the containers
5153
containerSelector: "ol, ul",
5254
// Distance the mouse has to travel to start dragging
5355
distance: 0,
5456
// The css selector of the drag handle
5557
handle: "",
58+
// The exact css path between the item and its subcontainers
59+
itemPath: "",
5660
// The css selector of the items
5761
itemSelector: "li",
5862
// Check if the dragged item may be inside the container.
@@ -527,7 +531,15 @@
527531
return !this.disabled && (!this.parentContainer || this.parentContainer.enabled())
528532
},
529533
$getChildren: function (parent, type) {
530-
return $(parent).find(this.rootGroup.options[type + "Selector"])
534+
var options = this.rootGroup.options,
535+
path = options[type + "Path"],
536+
selector = options[type + "Selector"]
537+
538+
parent = $(parent)
539+
if(path)
540+
parent = parent.find(path)
541+
542+
return parent.children(selector)
531543
},
532544
_serialize: function (parent, isContainer) {
533545
var that = this,

0 commit comments

Comments
 (0)