Copied to clipboard

Flag this post as spam?

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


  • Stefan Kip 1614 posts 4131 karma points c-trib
    Oct 24, 2016 @ 07:34
    Stefan Kip
    0

    Expand first node in content tree

    Hi!

    I'm trying to automatically expand the first node underneath 'Content' in the tree. This is what I've got so far:

    (function () {
        $(window).load(function () {
            setTimeout(function () {
                angular.element("#tree").scope().treeEventHandler.syncTree({ tree: 'Content', path: ["-1", "1062", "1132"], forceReload: false });
            }, 1000);
        });
    })();
    

    As you can see there are some obvious issues with this piece of code:

    • I need a setTimeout to wait for the tree to be loaded, which is not the way to go
    • The path is hard-coded
    • The tree does open the first root node (1062), but selects the node underneath it (1132), which is obvious, but not how I want it. If I leave 1132 out of the path, the root node is selected but not expanded
    • Expanding the tree after a refresh takes some time, it looks like the UI is locked for some time
    • There's no detection to check if the page is loaded after logging in, so without a node already selected via the URL

    First things first; is it possible to expand the root node without selecting the first child node?
    And is there an event for the tree which notifies when it's loaded?

    Appreciate any suggestions, thanks!

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Oct 24, 2016 @ 08:02
    Stefan Kip
    0

    Okay, so please bear with me, this is really ugly, but does what I want:

    $("ins:eq(0)").click();
    

    This does in fact do exactly what I'd like. So if there isn't a better way, this is fine with me.
    Now I just need to know how the other issues can be handled.

Please Sign in or register to post replies

Write your reply to:

Draft