@@ -186,32 +186,13 @@ angular.module('ui.sortable', [])
186
186
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' ) ) ;
187
187
}
188
188
189
- function getElementScope ( elementScopes , element ) {
190
- var result = null ;
191
- var x = null ;
192
- var i = null ;
193
- for ( i = 0 ; i < elementScopes . length ; i ++ ) {
194
- x = elementScopes [ i ] ;
195
- if ( x . element [ 0 ] === element [ 0 ] ) {
196
- result = x . scope ;
197
- break ;
189
+ function getElementContext ( elementScopes , element ) {
190
+ for ( var i = 0 ; i < elementScopes . length ; i ++ ) {
191
+ var c = elementScopes [ i ] ;
192
+ if ( c . element [ 0 ] === element [ 0 ] ) {
193
+ return c ;
198
194
}
199
195
}
200
- //If result is still null it means that the draggable (ng-repeat) item isn't a direct child of
201
- //the element containing the ui.sortable directive. This may be required when using the ui.sortable
202
- //directive with other directives that have isolated scopes. This will compare x.element[0]
203
- //with the closest ancestorof element[0] that has the ui-sortable attribute to get the applicable
204
- //element scope.
205
- if ( ! result ) {
206
- for ( i = 0 ; i < elementScopes . length ; i ++ ) {
207
- x = elementScopes [ i ] ;
208
- if ( x . element [ 0 ] === element [ 0 ] . closest ( '[ui-sortable]' ) ) {
209
- result = x . scope ;
210
- break ;
211
- }
212
- }
213
- }
214
- return result ;
215
196
}
216
197
217
198
function afterStop ( e , ui ) {
@@ -338,8 +319,8 @@ angular.module('ui.sortable', [])
338
319
var droptarget = ui . item . closest ( '[ui-sortable]' ) ;
339
320
ui . item . sortable . droptarget = droptarget ;
340
321
341
- var droptargetScope = getElementScope ( ui . item . sortable . _connectedSortables , droptarget ) ;
342
- ui . item . sortable . droptargetModel = droptargetScope . ngModel ;
322
+ var droptargetContext = getElementContext ( ui . item . sortable . _connectedSortables , droptarget ) ;
323
+ ui . item . sortable . droptargetModel = droptargetContext . scope . ngModel ;
343
324
344
325
// Cancel the sort (let ng-repeat do the sort for us)
345
326
// Don't cancel if this is the received list because it has
0 commit comments