Browse Source

#279: + dataIdAttr

pull/296/head
RubaXa 10 years ago
parent
commit
7dc8be5755
  1. 3
      README.md
  2. 10
      Sortable.js

3
README.md

@ -62,6 +62,7 @@ var sortable = new Sortable(el, {
filter: ".ignore-elements", // Selectors that do not lead to dragging (String or Function)
draggable: ".item", // Specifies which items inside the element should be sortable
ghostClass: "sortable-ghost", // Class name for the drop placeholder
dataIdAttr: 'data-id',
scroll: true, // or HTMLElement
scrollSensitivity: 30, // px, how near the mouse must be to an edge to start scrolling.
@ -399,7 +400,7 @@ For each element in the set, get the first element that matches the selector by
##### toArray():`String[]`
Serializes the sortable's item `data-id`'s into an array of string.
Serializes the sortable's item `data-id`'s (`dataIdAttr` option) into an array of string.
##### sort(order:`String[]`)

10
Sortable.js

@ -187,7 +187,8 @@
dataTransfer.setData('Text', dragEl.textContent);
},
dropBubble: false,
dragoverBubble: false
dragoverBubble: false,
dataIdAttr: 'data-id'
};
@ -726,12 +727,13 @@
el,
children = this.el.children,
i = 0,
n = children.length;
n = children.length,
options = this.options;
for (; i < n; i++) {
el = children[i];
if (_closest(el, this.options.draggable, this.el)) {
order.push(el.getAttribute('data-id') || _generateId(el));
if (_closest(el, options.draggable, this.el)) {
order.push(el.getAttribute(options.dataAttr) || _generateId(el));
}
}

Loading…
Cancel
Save