angular-ui-tree behaves strangely after updated list

204 Views Asked by At

I use the angular-ui-tree module for sorting a list, according to it's manual. Once an item is dropped, there's a list sent to the backend service, which saves the new sort order.

vm.treeOptions = {
    dropped : function(e) {
        restService.post('comments/' + currentId + '/settree', vm.myList);
    }
};

<div ui-tree="vm.treeOptions">
    <ol ui-tree-nodes ng-model="vm.myList">
        <li ng-repeat="item in vm.myList track by $index" ui-tree-node>
            <div class="tree-node tree-node-content">
                <i ui-tree-handle class="fa fa-arrows"></i> {{ item.name }}
            </div>
        </li>
    </ol>
</div>

But - once the saving process is done, there's an event fired (I am connected to a WebSockets server that emits an event once the content is updated, sending the new content along). It might give a slightly modified list due to some circumstances. So once the event is fired, I replace vm.myList with the new content.

    $scope.$on('ws:list_changed', function(m, data) {
        updateList(data);
        $scope.$apply();
    });

    function updateSpeakersList(data) {
        vm.speakersList = data;
    }

When I now change the order once more, I always get the "old" list, the vm.myList does show right, but has obviously not been sippering through to the dropped-function.

Does anybody know what I am missing here? Thanks a lot!

0

There are 0 best solutions below