Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 117f681

Browse files
committed
Merge pull request #194 from thgreasi/handlecreate
feat(sortable): initialize sortable with all user options, before first $watch
2 parents 382c88e + afa3505 commit 117f681

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/sortable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ angular.module('ui.sortable', [])
3838
update:null
3939
};
4040

41-
angular.extend(opts, uiSortableConfig);
41+
angular.extend(opts, uiSortableConfig, scope.$eval(attrs.uiSortable));
4242

4343
if (!angular.element.fn || !angular.element.fn.jquery) {
4444
$log.error('ui.sortable: jQuery should be included before AngularJS!');

test/sortable.e2e.callbacks.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,28 @@ describe('uiSortable', function() {
190190
});
191191
});
192192

193+
it('should call the create() callback when initialized', function() {
194+
inject(function($compile, $rootScope) {
195+
var element;
196+
$rootScope.$apply(function() {
197+
$rootScope.items = ['One', 'Two', 'Three'];
198+
$rootScope.opts = {
199+
create: function() {
200+
201+
}
202+
};
203+
spyOn($rootScope.opts, 'create');
204+
element = $compile('<ul ui-sortable="opts" ng-model="items"><li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li></ul>')($rootScope);
205+
});
206+
207+
host.append(element);
208+
209+
expect($rootScope.opts.create).toHaveBeenCalled();
210+
211+
$(element).remove();
212+
});
213+
});
214+
193215
});
194216

195217
});

0 commit comments

Comments
 (0)