jquery - AngularJS ui-sortable - unable to move items -


i'm working on angularjs project feature users can move items across arrays. 1 array shown on initialization; when users drag item , mouseover on desired array name, particular array shown instead , users can drop item there.

below codepen project illustrate feature: http://codepen.io/anon/pen/ppwpqv

i have gotten kinda working, there 2 scenarios i'm experiencing problems:

  1. when there 3 arrays, i'm able move items across them (even empty array). last item in array cannot moved. also, placeholder appear after considerable amount of time.

  2. when there 2 arrays , 1 empty, i'm unable move items @ all. (try commenting out 1 of non-empty array.)

if arrays shown on initialization instead of show on mouseover (i.e. removing ng-show attribute), sortable feature work seamlessly.

i've spent time trying figure out didn't managed head around. advice appreciated!


js

var myapp = angular.module("app", ['ui.sortable']);  myapp.controller("maincontroller", function ($scope, $timeout) {      $scope.item_lists = [         ['1', '2', '3', '4', '5'],         ['a', 'b', 'c', 'd', 'e'], // comment out line test scenario 2         []     ]      $scope.sortable = {         appendto: '.container-fluid',         helper: 'clone',         connectwith: '.items',         droponempty: true,         cursor: 'move',         placeholder: 'placeholder'     };       $scope.setvisiblearray = function (value) {         $scope.visible_array_id = value;     };      $scope.visible_array_id = 0;  }); 

html

<div ng-app="app" class="container-fluid" ng-controller="maincontroller">   <div class="folder">     <div ng-repeat="item_list in item_lists" ng-mouseover="setvisiblearray($index)" ng-class="{'highlighted': visible_array_id == $index}">array {{$index}}</div>   </div>   <div class="items" ng-repeat="item_list in item_lists" ui-sortable="sortable" ng-model="item_list" ng-show="visible_array_id == $index"> <!-- sortable works seamlessly if ng-show attribute removed. -->     <div ng-repeat="item in item_list">item {{item}}</div>   </div> </div> 


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -