mtch9
mtch9

Reputation: 308

Angular ui-tree detect drag event between connected trees

I would like to detect event when item was dragged from tree#1 and dropped to tree#2. In this case i would like to call a specific http action to save it. I use the dropped event with actions inside one tree, but i can't manage it when i move item between trees. I tried to find differences in event 'dest' and 'source' objects, but did not found any solution.

Upvotes: 1

Views: 1078

Answers (1)

mtch9
mtch9

Reputation: 308

I solved my problem. I added custom data-tree-type attribute to the tree

 <div ui-tree="treeOptions" id="tree-root" data-tree-type="mainTree" data-drag-delay="200">
        <ol ui-tree-nodes ng-model="data">
            <li ng-repeat="node in data" data-info="{{node.pageId}}" ui-tree-node ng-include="'nodes_renderer.html'"></li>
        </ol>
</div>

and then in angular-ui-tree.js in directive uiTree i added watch function

scope.$watch(attrs.treeType, function (val) {
     scope.treeType = attrs.treeType;
});

Now i can compare treeType attributes in droped event dest and source objects.

Upvotes: 1

Related Questions