Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion dist/ng-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@
* moveTo: moveTo, isSameParent: isSameParent, isOrderChanged: isOrderChanged, eventArgs: eventArgs, apply: apply}}
*/
dragItem: function (item) {
function getAncestorProperty(object, property){
for(var curScope = object; curScope.$parent; curScope = curScope.$parent){
if(curScope.hasOwnProperty(property)) {
return curScope[property];
}
}
}

return {
index: item.index(),
Expand Down Expand Up @@ -317,7 +324,7 @@

// if the dragged item is not already there, insert the item. This avoids ng-repeat dupes error
if (this.parent.options.allowDuplicates || this.parent.modelValue.indexOf(this.source.modelValue) < 0) {
this.parent.insertItem(this.index, this.source.modelValue);
this.parent.insertItem(this.index, getAncestorProperty(this.source, 'modelValue'));
}
} else if (!this.parent.options.clone) { // prevent drop inside sortables that specify options.clone = true
// clone the model value as well
Expand Down Expand Up @@ -659,6 +666,14 @@
}
});

scope.index = function () {
for(var curScope = scope; curScope.$parent; curScope = curScope.$parent){
if(curScope.hasOwnProperty('$index')) {
return curScope.$index;
}
}
};

scope.$on('$destroy', function () {
angular.element($document[0].body).unbind('keydown', escapeListen);
});
Expand Down
Loading