@@ -37,6 +37,16 @@ angular.module('ui.sortable', [])
37
37
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' ) ) ;
38
38
}
39
39
40
+ function getElementScope ( elementScopes , element ) {
41
+ for ( var i = 0 ; i < elementScopes . length ; i ++ ) {
42
+ var x = elementScopes [ i ] ;
43
+ if ( x . element [ 0 ] === element [ 0 ] ) {
44
+ return x . scope ;
45
+ }
46
+ }
47
+ return null ;
48
+ }
49
+
40
50
function afterStop ( e , ui ) {
41
51
ui . item . sortable . _destroy ( ) ;
42
52
}
@@ -115,7 +125,7 @@ angular.module('ui.sortable', [])
115
125
} ;
116
126
} ;
117
127
118
- callbacks . activate = function ( /* e, ui*/ ) {
128
+ callbacks . activate = function ( e , ui ) {
119
129
// We need to make a copy of the current element's contents so
120
130
// we can restore it after sortable has messed it up.
121
131
// This is inside activate (instead of start) in order to save
@@ -140,10 +150,20 @@ angular.module('ui.sortable', [])
140
150
// exact match with the placeholder's class attribute to handle
141
151
// the case that multiple connected sortables exist and
142
152
// the placehoilder option equals the class of sortable items
143
- var excludes = element . find ( '[class="' + phElement . attr ( 'class' ) + '"]' ) ;
153
+ var excludes = element . find ( '[class="' + phElement . attr ( 'class' ) + '"]:not([ng-repeat], [data-ng-repeat]) ' ) ;
144
154
145
155
savedNodes = savedNodes . not ( excludes ) ;
146
156
}
157
+
158
+ // save the directive's scope so that it is accessible from ui.item.sortable
159
+ var connectedSortables = ui . item . sortable . _connectedSortables || [ ] ;
160
+
161
+ connectedSortables . push ( {
162
+ element : element ,
163
+ scope : scope
164
+ } ) ;
165
+
166
+ ui . item . sortable . _connectedSortables = connectedSortables ;
147
167
} ;
148
168
149
169
callbacks . update = function ( e , ui ) {
@@ -154,8 +174,9 @@ angular.module('ui.sortable', [])
154
174
ui . item . sortable . dropindex = ui . item . index ( ) ;
155
175
var droptarget = ui . item . parent ( ) ;
156
176
ui . item . sortable . droptarget = droptarget ;
157
- var attr = droptarget . attr ( 'ng-model' ) || droptarget . attr ( 'data-ng-model' ) ;
158
- ui . item . sortable . droptargetModel = droptarget . scope ( ) . $eval ( attr ) ;
177
+
178
+ var droptargetScope = getElementScope ( ui . item . sortable . _connectedSortables , droptarget ) ;
179
+ ui . item . sortable . droptargetModel = droptargetScope . ngModel ;
159
180
160
181
// Cancel the sort (let ng-repeat do the sort for us)
161
182
// Don't cancel if this is the received list because it has
0 commit comments