angularjs-dragula
angularjs-dragula copied to clipboard
When using a filtered ng-repeat the DOM element index differs from model index
Currently you cannot drag items while the list is filtered. dragula becomes confused with the array index. In this plunker example you can try to search for "t" and then drag and drop "them" within the list. You will notice, that the hidden "Explore" will be moved instead.
http://plnkr.co/edit/bKNeo9cyKyjY3GpJcIhY?p=preview
Plnkr taken from here: https://github.com/bevacqua/angular-dragula/issues/29 Also highlighted that would be issue with this pull request: https://github.com/bevacqua/angular-dragula/pull/9
@debslord I'm not sure if it'll help you or not but, my team had the same problem today.
I edited service.js line #50 to include the following -
if (dropElm.hasAttribute('ng-repeat')) { dropElmModel = angular.element(dropElm).scope()[dropElm.getAttribute('ng-repeat').split(' ')[0]]; dragIndex = sourceModel.indexOf(dropElmModel); }
This finds the index of the model in unfiltered source. It's barbaric and but, it gets the job done.
+1 not using filter exactly but it does not work when using pipes that alter the positioning of items on screen