Angular Ui Sortable Callback
Is there a way to set a callback function with angular ui's sortable? I'd like to add ng-update='foo()' to the tbody tag below and have foo run whenever the list changes.
Solution 1:
You can now specify the update function in the ui-sortable
attribute, like this:
<tbodyui-sortable="{update: foo()}">
But there still are a few issues with the sortable directive, like in this example. They are currently discussed here.
Solution 2:
I prefer to use an options hash with my update callback defined, in my scope like this:
$scope.sortableOptions = {
disabled: false,
update: function(event) {
return$scope.sortableUpdated = true;
}
};
and in the template:
<divui-sortable="sortableOptions"> ...
Solution 3:
Reading through the ui-sortable file (there isn't a demo of it on the angular-ui homepage, wonder why?) here, I see that it allows for 2 callbacks -> start and update, for before and after the change you trigger. So something like this should work:
<tbody id="existingStockResults" ui-sortable update="myCallback()" ng-model="processes">
Post a Comment for "Angular Ui Sortable Callback"