diff --git a/src/sortable.js b/src/sortable.js index 936f528..8487ad8 100644 --- a/src/sortable.js +++ b/src/sortable.js @@ -76,7 +76,7 @@ angular.module('ui.sortable', []) $timeout(function() { // ensure that the jquery-ui-sortable widget instance // is still bound to the directive's element - if (!!element.data('ui-sortable')) { + if (!!element.sortable('instance')) { element.sortable('refresh'); } }, 0, false); @@ -87,7 +87,7 @@ angular.module('ui.sortable', []) // since the drag has started, the element will be // absolutely positioned, so we check its siblings var siblings = ui.item.siblings(); - angular.element(e.target).data('ui-sortable').floating = isFloating(siblings); + angular.element(e.target).sortable('instance').floating = isFloating(siblings); } // Save the starting position of dragged item @@ -263,13 +263,13 @@ angular.module('ui.sortable', []) scope.$watch('uiSortable', function(newVal /*, oldVal*/) { // ensure that the jquery-ui-sortable widget instance // is still bound to the directive's element - if (!!element.data('ui-sortable')) { + if (!!element.sortable('instance')) { angular.forEach(newVal, function(value, key) { // if it's a custom option of the directive, // handle it approprietly if (key in directiveOpts) { if (key === 'ui-floating' && (value === false || value === true)) { - element.data('ui-sortable').floating = value; + element.sortable('instance').floating = value; } opts[key] = value; diff --git a/test/sortable.spec.js b/test/sortable.spec.js index fd1a988..ea99908 100644 --- a/test/sortable.spec.js +++ b/test/sortable.spec.js @@ -77,6 +77,25 @@ describe('uiSortable', function() { }); }); + it('should refresh sortable properly after an apply [data-* anotation]', function() { + inject(function($compile, $rootScope, $timeout) { + var element; + var childScope = $rootScope.$new(); + element = $compile('