Permalink
Browse files

added new options: (container|item)Path

closes #20
  • Loading branch information...
1 parent 38ebf09 commit 6936bb4d8cde9f553317ab5884ca58d210df7169 @johnny committed Jul 15, 2013
Showing with 17 additions and 4 deletions.
  1. +2 −2 source/_table.html.haml
  2. +2 −1 source/js/examples/table.js
  3. +13 −1 source/js/jquery-sortable.js
View
@@ -19,12 +19,12 @@
%p= show_code_button
.span4
%h3 Sortable Rows
- %table.table.table-striped.table-bordered
+ %table.table.table-striped.table-bordered.sorted_table
%thead
%tr
%th A Column
%th B Column
- %tbody.sorted_table
+ %tbody
= iterate(6) do |i, name|
%tr
%td A #{name}
@@ -1,7 +1,8 @@
$(function () {
// Sortable rows
$('.sorted_table').sortable({
- containerSelector: 'tbody',
+ containerSelector: 'table',
+ itemPath: '> tbody',
itemSelector: 'tr',
placeholder: '<tr class="placeholder"/>'
})
@@ -47,12 +47,16 @@
// This is executed after the placeholder has been moved.
afterMove: function ($placeholder, container) {
},
+ // The exact css path between the container and its items, e.g. "> tbody"
+ containerPath: "",
// The css selector of the containers
containerSelector: "ol, ul",
// Distance the mouse has to travel to start dragging
distance: 0,
// The css selector of the drag handle
handle: "",
+ // The exact css path between the item and its subcontainers
+ itemPath: "",
// The css selector of the items
itemSelector: "li",
// Check if the dragged item may be inside the container.
@@ -527,7 +531,15 @@
return !this.disabled && (!this.parentContainer || this.parentContainer.enabled())
},
$getChildren: function (parent, type) {
- return $(parent).find(this.rootGroup.options[type + "Selector"])
+ var options = this.rootGroup.options,
+ path = options[type + "Path"],
+ selector = options[type + "Selector"]
+
+ parent = $(parent)
+ if(path)
+ parent = parent.find(path)
+
+ return parent.children(selector)
},
_serialize: function (parent, isContainer) {
var that = this,

0 comments on commit 6936bb4

Please sign in to comment.