Skip to content

Commit ba86ae0

Browse files
authored
Merge pull request #1 from oclockvn/master
Fix issue items are always cloned
2 parents 9b07d7d + 370c6dc commit ba86ae0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

knockout-sortable.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@
119119
var removeOperation = currentOperation.event.type === 'remove' ? currentOperation : existingOperation,
120120
addOperation = currentOperation.event.type === 'add' ? currentOperation : existingOperation;
121121

122+
addOperation.event.groupOption = parentBindings.sortable.options.group;
123+
122124
moveItem(itemVM, removeOperation.collection, addOperation.collection, addOperation.event.clone, addOperation.event);
123125
}
124126
},
@@ -151,7 +153,13 @@
151153
fromArray.splice(originalIndex, 1);
152154
// Update the array, this will also remove sortables "unbound" clone
153155
from.valueHasMutated();
154-
if (clone && from !== to) {
156+
157+
var groupOption = e.groupOption;
158+
// See the option at https://github.com/SortableJS/Sortable#options
159+
// group: { name: 'shared', pull: 'clone' }
160+
var cloneable = typeof groupOption === 'object' && groupOption.pull === 'clone';
161+
162+
if (cloneable && clone && from !== to) {
155163
// Read the item
156164
fromArray.splice(originalIndex, 0, itemVM);
157165
// Force knockout to update

0 commit comments

Comments
 (0)