Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save waaronking/5ea0f0734150ab6e2e7a to your computer and use it in GitHub Desktop.
Save waaronking/5ea0f0734150ab6e2e7a to your computer and use it in GitHub Desktop.
<div class="container" ng-app="dragndropdemo">
<div class="row" ng-controller="dragndropdemo">
<div id="names" class="form-inline draggable-group" role="form">
<div class="form-group has-feedback transition" ng-repeat-reorder='name in names' ng-repeat-reorder-handle="i.fa.fa-bars">
<input class="form-control form-inline player" type='text'
ng-change='checkForNameDelete($index)'
ng-model='name.val'
ng-class="{'last-player': $index == names.length-1}">
<i class="fa fa-bars form-control-feedback"></i>
</div>
<!-- tabindex logic is +1 due to 0 start of $index and then add on to start at the correct point, make sure to use tabindex='{{players.length + offset}}' on everything that gets focus after this -->
</div>
</div>
</div>
angular.module("dragndropdemo", ['ngRepeatReorder']);
function dragndropdemo($scope) {
$scope.names = [{val:'bob'},{val:'lucy'},{val:'john'},{val:'luke'},{val:'han'}];
$scope.checkForNameDelete = function($index){
if($scope.names[$index].val === ''){
$scope.names.splice($index, 1);
}
};
};
.draggable-group {
width: 277px;
}
.ng-repeat-reorder-parent, [ng-repeat-reorder]{
z-index: 10;
position: relative;
}
[ng-repeat-reorder].dragging{
z-index: 11;
position: absolute;
}
.active-drag-below {
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment