@@ -47,6 +47,16 @@ angular.module('ui.sortable', [])
47
47
return ( / l e f t | r i g h t / ) . test ( item . css ( 'float' ) ) || ( / i n l i n e | t a b l e - c e l l / ) . test ( item . css ( 'display' ) ) ;
48
48
}
49
49
50
+ function getElementScope ( elementScopes , element ) {
51
+ for ( var i = 0 ; i < elementScopes . length ; i ++ ) {
52
+ var x = elementScopes [ i ] ;
53
+ if ( x . element [ 0 ] === element [ 0 ] ) {
54
+ return x . scope ;
55
+ }
56
+ }
57
+ return null ;
58
+ }
59
+
50
60
function afterStop ( e , ui ) {
51
61
ui . item . sortable . _destroy ( ) ;
52
62
}
@@ -126,7 +136,7 @@ angular.module('ui.sortable', [])
126
136
} ;
127
137
} ;
128
138
129
- callbacks . activate = function ( /* e, ui*/ ) {
139
+ callbacks . activate = function ( e , ui ) {
130
140
// We need to make a copy of the current element's contents so
131
141
// we can restore it after sortable has messed it up.
132
142
// This is inside activate (instead of start) in order to save
@@ -151,10 +161,20 @@ angular.module('ui.sortable', [])
151
161
// exact match with the placeholder's class attribute to handle
152
162
// the case that multiple connected sortables exist and
153
163
// the placehoilder option equals the class of sortable items
154
- var excludes = element . find ( '[class="' + phElement . attr ( 'class' ) + '"]' ) ;
164
+ var excludes = element . find ( '[class="' + phElement . attr ( 'class' ) + '"]:not([ng-repeat], [data-ng-repeat]) ' ) ;
155
165
156
166
savedNodes = savedNodes . not ( excludes ) ;
157
167
}
168
+
169
+ // save the directive's scope so that it is accessible from ui.item.sortable
170
+ var connectedSortables = ui . item . sortable . _connectedSortables || [ ] ;
171
+
172
+ connectedSortables . push ( {
173
+ element : element ,
174
+ scope : scope
175
+ } ) ;
176
+
177
+ ui . item . sortable . _connectedSortables = connectedSortables ;
158
178
} ;
159
179
160
180
callbacks . update = function ( e , ui ) {
@@ -165,8 +185,9 @@ angular.module('ui.sortable', [])
165
185
ui . item . sortable . dropindex = ui . item . index ( ) ;
166
186
var droptarget = ui . item . parent ( ) ;
167
187
ui . item . sortable . droptarget = droptarget ;
168
- var attr = droptarget . attr ( 'ng-model' ) || droptarget . attr ( 'data-ng-model' ) ;
169
- ui . item . sortable . droptargetModel = droptarget . scope ( ) . $eval ( attr ) ;
188
+
189
+ var droptargetScope = getElementScope ( ui . item . sortable . _connectedSortables , droptarget ) ;
190
+ ui . item . sortable . droptargetModel = droptargetScope . ngModel ;
170
191
171
192
// Cancel the sort (let ng-repeat do the sort for us)
172
193
// Don't cancel if this is the received list because it has
0 commit comments