Closed inquota closed 8 years ago
Hi, At this moment I am able to load the children asynchronous with the toggle function. The weird thing is, the children will be displayed on the 2nd click.
The treecontrol got this value: on-node-toggle="ctrl.fetchChildNodes(node, expanded)"
on-node-toggle="ctrl.fetchChildNodes(node, expanded)"
This is my Angular method:
controllerScope.fetchChildNodes = function (node, expanded) { if(expanded) { if (node.hasOwnProperty('hasChildren')) { var token = jQuery('meta[name="csrf_token"]').attr('content'); jQuery.ajax({ method: 'POST', headers: {'X-XSRF-TOKEN': token}, url: '/ajax/nodes/children', data: { nodeId: node.id } }) .success(function (data) { node.children = data; }) .done(function (data) { node.children = data; }) .fail() } } };
Why does the data only be showed on the 2nd click?
https://www.dropbox.com/s/ynunsrpcgu24vfp/angular-tree-control-lazy-load.png?dl=0
Thanks!
you need to use $scope.$apply() in the ajax callback.
$scope.$apply()
Thanks, issue solved :)
Hi, At this moment I am able to load the children asynchronous with the toggle function. The weird thing is, the children will be displayed on the 2nd click.
The treecontrol got this value:
on-node-toggle="ctrl.fetchChildNodes(node, expanded)"
This is my Angular method:
Why does the data only be showed on the 2nd click?
https://www.dropbox.com/s/ynunsrpcgu24vfp/angular-tree-control-lazy-load.png?dl=0
Thanks!