Loading ...
Sorry, an error occurred while loading the content.
 

changing css properties onExpand

Expand Messages
  • viofis
    This is probably a stupid question, but I can t get this to work: tree.onExpand = function(node) { getEl().style.background= #000000 ; } I need to change the
    Message 1 of 3 , Feb 15, 2006
      This is probably a stupid question, but I can't get this to work:

      tree.onExpand = function(node) {
      getEl().style.background="#000000";
      }

      I need to change the background color of the node when it's expanded.
      Obviously i'm doing something wrong here, but not sure what.

      Any suggestions?

      - Vadim
    • Christian Heilmann
      ... getEl() is a function that does return an element, but is not an element in itself. Therefore it has no style object you can access. try var myel=getEl();
      Message 2 of 3 , Feb 15, 2006
        > This is probably a stupid question, but I can't get
        > this to work:
        >
        > tree.onExpand = function(node) {
        > getEl().style.background="#000000";
        > }
        >
        > I need to change the background color of the node
        > when it's expanded.
        > Obviously i'm doing something wrong here, but not
        > sure what.

        getEl() is a function that does return an element, but
        is not an element in itself. Therefore it has no style
        object you can access.

        try

        var myel=getEl();
        myel.style.background='#000';

        It might be cleverer to assign a class to the element
        though, as this makes it easier to maintain the look
        and feel outside the JavaScript.

        By the way, it seems that there are classes assigned
        to the different states, shouldn't changing them do
        what you expect?
        http://developer.yahoo.net/yui/treeview/index.html#using

        HTH
        Chris
        http://www.wait-till-i.com




        ___________________________________________________________
        To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
      • Adam Moore
        ... var tree = new YAHOO.util.TreeView( hostdiv ); tree.onExpand = function(node) { // Change the background for the div that contains the entire node, //
        Message 3 of 3 , Feb 15, 2006
          On Wed, Feb 15, 2006 at 08:57:25PM -0000, viofis wrote:
          > This is probably a stupid question, but I can't get this to work:
          >
          > tree.onExpand = function(node) {
          > getEl().style.background="#000000";
          > }

          var tree = new YAHOO.util.TreeView("hostdiv");
          tree.onExpand = function(node) {
          // Change the background for the div that contains the entire node,
          // including the node's children. Probably not what you want.
          //
          // node.getEl().style.backgroundColor="#000000";

          // Change the background of the anchor tag that contains the label
          node.getLabelEl().style.backgroundColor="#000000";
          };


          -Adam
        Your message has been successfully submitted and would be delivered to recipients shortly.