Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • deniz 3 posts 23 karma points
    Jun 27, 2014 @ 12:53
    deniz
    0

    How to delete a node from a custom Tree

    Hi guys!

    I'm pretty new to the Umbraco development and try to create a custom section.

    Creating the tree, controllers and views so far.

    Now i've got a structure like this:

    -Rootelement

    --List

    ---Listitem 1... 

    ---Listitem n

    My Listitem got a rightclick optionitem "delete" and if i click this one it should be deleted. 

    When I press the item umbraco looking for the delete view that already exists but i cant get any information about the Listitem, that should be deleted, in the deletecontroller. 

    I look at the html code and see that Umbraco use the "performaction" method. In the umbraco.Controller.js i found the method. it looks like:

     

    /**

     * @ngdoc controller

     * @name Umbraco.Dialogs.LegacyDeleteController

     * @function

     * @description

     * The controller for deleting content

     */

    function LegacyDeleteController($scope, legacyResource, treeService, navigationService) {

        $scope.performDelete = function() {

            //mark it for deletion (used in the UI)

            $scope.currentNode.loading = true;

            legacyResource.deleteItem({            

                nodeId: $scope.currentNode.id,

                nodeType: $scope.currentNode.nodeType,

                alias: $scope.currentNode.name,

            }).then(function () {

                $scope.currentNode.loading = false;

                //TODO: Need to sync tree, etc...

                treeService.removeNode($scope.currentNode);

                navigationService.hideMenu();

            });

        };

       $scope.cancel = function() {

            navigationService.hideDialog();

        };

    }

    angular.module("umbraco").controller("Umbraco.Dialogs.LegacyDeleteController", LegacyDeleteController);

     

    But if i try to get the currenNode of $scope in my Controller the answer of the console ist just:

    TypeError: Cannot set property 'loading' of undefined

    So how can i get the item that should be delete?
    Best regards
    Deniz
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies