Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

SecurityAdmin js tree - what js library?


Reply


778 Views

Avatar
dominicB

Community Member, 14 Posts

4 January 2011 at 11:40pm

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.removeNodeClass('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]
alert($(selectedNode.id));

//none of these basic prototype calls work "bla bla extend is not a function...."
//either together or on their own
          $(selectedNode.id).extend();
$(selectedNode.id).getElementsBySelector();
$(selectedNode.id).select();

//basic jquery method call doesn't work "bla bla height is not a function..."
alert($selectedNode.id).height();

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

            selectedNode.addNodeClass('selected');
            selectedNode.selected = true;
            deletegroup.selectedNodes[idx] = true;
            
            
            
            
         }
      }
      
      return false;
   },