Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

<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!

like image 872
kreek Avatar asked Nov 21 '12 19:11

kreek


Video Answer


1 Answers

You can now specify the update function in the ui-sortable attribute, like this:

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

But there still are a few issues with the sortable directive, like in this example. They are currently discussed here.

like image 193
Jill-Jênn Vie Avatar answered Sep 24 '22 03:09

Jill-Jênn Vie