Jump to:

5554 Posts in 1742 Topics by 1227 members

Customising the CMS

SilverStripe Forums » Customising the CMS » SecurityAdmin js tree - what js library?

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 714 Views
  • dominicB
    Community Member
    14 Posts

    SecurityAdmin js tree - what js library? Link to this post

    I'm cloning SecurityAdmin and bending it to my own ends, ie editing some custom objects. It's mostly going well. I'm trying to add a little bit of functionality to the nav tree so that when I select an item in the tree to delete it, all its descendants are selected too. Because otherwise they're left in the database as orphans when the ancestor is deleted.

    I know I can do it easily in the backend, but I want the selection to happen in the front end because then it's obvious to the user what's happening.

    My problem is, what js library (if any) is in use in the tree? I got the selected node, and I've tried prototype functions and jQuery functions on it and they don't exist. So maybe it isn't using them, and maybe I'm just not doing it right? any ideas? Here's a bit of code originally from SecurityAdmin_left.js

    treeSelectionChanged : function(selectedNode) {
          var idx = $('sitetree').getIdxOf(selectedNode);

          if(selectedNode.className.indexOf('nodelete') == -1) {
             if(selectedNode.selected) {
                selectedNode.selected = false;
                deletegroup.selectedNodes[idx] = false;
             } else {
              // I added the line below and it works
              alert('select all the children too');

    // this works too - it displays [HTMLLIElement]

    //none of these basic prototype calls work "bla bla extend is not a function...."
    //either together or on their own

    //basic jquery method call doesn't work "bla bla height is not a function..."

    //standard DOM methods work fine
    oDescendants = $(selectedNode.id).getElementsByTagName('LI');
    for (var i=0;i<oDescendants.length;i++) alert(oDescendants.item(i).id);

                selectedNode.selected = true;
                deletegroup.selectedNodes[idx] = true;
          return false;

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.