Umbraco 7: How do I update the tree structure in my custom partition?
I have created a dedicated section in umbraco to manage some data in a SQL database.
I can edit the items ok, but when adding, I need to refresh the page to see the new line in the custom tree on the left.
How can I trigger my custom tree to update using AngularJS? My tree is called "clients".
I tried to debug the code and look at the source to find this event, but I can't figure out how to do it.
Is there a way that I can call on in umbTreeDirective
some way? Or a subscription event?
I'm new to AngularJS and struggling a bit.
source to share
You are looking for navigationService .
This line is an example of calling syncTree:
navigationService.syncTree({ tree: 'clients', path: content.path, forceReload: false, activate: true });
Here's the contrived spaghetti promised, but a complete example:
angular.module("umbraco")
.directive('nowplaying', ['navigationService', 'contentResource', 'contentEditingHelper', function (navigationService, contentResource, contentEditingHelper) {
//spaghetti example to create new document
contentResource.getScaffold(parentId, alias)
.then(function (scaffold) {
var myDoc = scaffold;
myDoc.name = name;
//we have minimum to publish
contentResource.publish(myDoc, true, [''])
.then(function (content) {
$scope.newlyCreatedNode = content;
//Sync ('refresh') the tree!
navigationService.syncTree({ tree: 'clients', path: content.path, forceReload: false, activate: true });
});
});
}]);
All Belle Documentation lives here . -I'm not sure if it is actively maintained, I can safely say that one or two signatures have changed since it was first published. This aside, this is the best resource I know to interact with all vulnerable umbraco modules and services.
source to share