Angular ui sortable callback

Is there a way to set the callback function using angular ui sortable? I would like to add ng-update = "foo ()" to the tbody tag below and run foo each time the list changes.

<tbody id="existingStockResults" ui-sortable ng-model="processes"> <tr ng-repeat="process in processes" ng-class="{odd: $index%2 == 0, even: $index%2 != 0}"> <td>{{process.process}}</td> <td>{{process.vendor}}</td> <td>{{process.desc}}</td> <td>{{process.cost}}</td> <td><a href="#" ng-click="editProcess($index)">edit</a></td> <td><a href="#" ng-click="removeProcess($index)">remove</a></td> </tr> </tbody> 

thanks!

+8
javascript angularjs angular-ui angular-ui-sortable
source share
3 answers

Now you can specify the update function in the ui-sortable , for example:

 <tbody ui-sortable="{update: foo()}"> 

But there are still a few problems with the sortable directive, for example, in this example . They are currently being discussed here .

+6
source share

I prefer to use the parameter hash with my update callback, in my scope:

 $scope.sortableOptions = { disabled: false, update: function(event) { return $scope.sortableUpdated = true; } }; 

and in the template:

 <div ui-sortable="sortableOptions"> ... 
+5
source share

Reading through a ui-sortable file (it is not on the angular -ui homepage, I wonder why?) Here , I see that it allows you to use 2 callbacks β†’ start and update, before and after the change that you run. So something like this should work:

 <tbody id="existingStockResults" ui-sortable update="myCallback()" ng-model="processes"> 
+3
source share

All Articles