@@ -302,6 +302,67 @@ describe('uiSortable', function() {
302302
303303 } ) ;
304304
305+ it ( 'should not initialize a disabled sortable' , function ( ) {
306+ inject ( function ( $compile , $rootScope ) {
307+ var element ;
308+ var childScope = $rootScope . $new ( ) ;
309+ spyOn ( angular . element . fn , 'sortable' ) ;
310+
311+ childScope . items = [ 'One' , 'Two' , 'Three' ] ;
312+ childScope . opts = {
313+ disabled : true
314+ } ;
315+ element = $compile ( '<ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items">{{ item }}</li></ul>' ) ( childScope ) ;
316+
317+ expect ( angular . element . fn . sortable ) . not . toHaveBeenCalled ( ) ;
318+ } ) ;
319+ } ) ;
320+
321+ it ( 'should lazily initialize a latelly enabled sortable (set disabled = false)' , function ( ) {
322+ inject ( function ( $compile , $rootScope ) {
323+ var element ;
324+ var childScope = $rootScope . $new ( ) ;
325+ spyOn ( angular . element . fn , 'sortable' ) ;
326+
327+ childScope . items = [ 'One' , 'Two' , 'Three' ] ;
328+ childScope . opts = {
329+ disabled : true
330+ } ;
331+ element = $compile ( '<ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items">{{ item }}</li></ul>' ) ( childScope ) ;
332+
333+ expect ( angular . element . fn . sortable ) . not . toHaveBeenCalled ( ) ;
334+
335+ $rootScope . $apply ( function ( ) {
336+ childScope . opts . disabled = false ;
337+ } ) ;
338+
339+ expect ( angular . element . fn . sortable ) . toHaveBeenCalled ( ) ;
340+ } ) ;
341+ } ) ;
342+
343+ it ( 'should lazily initialize a latelly enabled sortable (delete disabled option)' , function ( ) {
344+ inject ( function ( $compile , $rootScope ) {
345+ var element ;
346+ var childScope = $rootScope . $new ( ) ;
347+ spyOn ( angular . element . fn , 'sortable' ) ;
348+
349+ childScope . items = [ 'One' , 'Two' , 'Three' ] ;
350+ childScope . opts = {
351+ disabled : true
352+ } ;
353+ element = $compile ( '<ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items">{{ item }}</li></ul>' ) ( childScope ) ;
354+
355+ expect ( angular . element . fn . sortable ) . not . toHaveBeenCalled ( ) ;
356+
357+ $rootScope . $apply ( function ( ) {
358+ childScope . opts = { } ;
359+ } ) ;
360+
361+ expect ( angular . element . fn . sortable ) . toHaveBeenCalled ( ) ;
362+ } ) ;
363+ } ) ;
364+
365+
305366 } ) ;
306367
307368
0 commit comments