@@ -27,6 +27,16 @@ angular.module('ui.sortable', [])
27
27
return first ;
28
28
}
29
29
30
+ function getSortableWidgetInstance ( element ) {
31
+ // this is a fix to support jquery-ui prior to v1.11.x
32
+ // otherwise we should be using `element.sortable('instance')`
33
+ var data = element . data ( 'ui-sortable' ) ;
34
+ if ( data && typeof data === 'object' && data . widgetFullName === 'ui-sortable' ) {
35
+ return data ;
36
+ }
37
+ return null ;
38
+ }
39
+
30
40
function hasSortingHelper ( element , ui ) {
31
41
var helperOption = element . sortable ( 'option' , 'helper' ) ;
32
42
return helperOption === 'clone' || ( typeof helperOption === 'function' && ui . item . sortable . isCustomHelperUsed ( ) ) ;
@@ -76,7 +86,7 @@ angular.module('ui.sortable', [])
76
86
$timeout ( function ( ) {
77
87
// ensure that the jquery-ui-sortable widget instance
78
88
// is still bound to the directive's element
79
- if ( ! ! element . sortable ( 'instance' ) ) {
89
+ if ( ! ! getSortableWidgetInstance ( element ) ) {
80
90
element . sortable ( 'refresh' ) ;
81
91
}
82
92
} , 0 , false ) ;
@@ -87,7 +97,8 @@ angular.module('ui.sortable', [])
87
97
// since the drag has started, the element will be
88
98
// absolutely positioned, so we check its siblings
89
99
var siblings = ui . item . siblings ( ) ;
90
- angular . element ( e . target ) . sortable ( 'instance' ) . floating = isFloating ( siblings ) ;
100
+ var sortableWidgetInstance = getSortableWidgetInstance ( angular . element ( e . target ) ) ;
101
+ sortableWidgetInstance . floating = isFloating ( siblings ) ;
91
102
}
92
103
93
104
// Save the starting position of dragged item
@@ -263,13 +274,14 @@ angular.module('ui.sortable', [])
263
274
scope . $watch ( 'uiSortable' , function ( newVal /*, oldVal*/ ) {
264
275
// ensure that the jquery-ui-sortable widget instance
265
276
// is still bound to the directive's element
266
- if ( ! ! element . sortable ( 'instance' ) ) {
277
+ var sortableWidgetInstance = getSortableWidgetInstance ( element ) ;
278
+ if ( ! ! sortableWidgetInstance ) {
267
279
angular . forEach ( newVal , function ( value , key ) {
268
280
// if it's a custom option of the directive,
269
281
// handle it approprietly
270
282
if ( key in directiveOpts ) {
271
283
if ( key === 'ui-floating' && ( value === false || value === true ) ) {
272
- element . sortable ( 'instance' ) . floating = value ;
284
+ sortableWidgetInstance . floating = value ;
273
285
}
274
286
275
287
opts [ key ] = value ;
0 commit comments