[CLOSED] Changing a Toggle Buttons Icon

  1. #1

    [CLOSED] Changing a Toggle Buttons Icon

    Hi all

    I try to change a Toggle Buttons Icon

      button.toggle(!button.pressed);
      
      if (button.pressed) {
        button.setIconCls('#BellStop');
      } else {
        button.setIconCls('#ButtonWhite');
      }
    But the Icon doesn't appear/change ?

    What's the solution here ?

    Peter
    Last edited by Daniil; May 09, 2013 at 4:58 AM. Reason: [CLOSED]
  2. #2
    Quote Originally Posted by Peter.Treier View Post
    Hi all

    I try to change a Toggle Buttons Icon

      button.toggle(!button.pressed);
      
      if (button.pressed) {
        button.setIconCls('#BellStop');
      } else {
        button.setIconCls('#ButtonWhite');
      }
    Isn't # for targeting dom element with a certain id? You should declare your css as :

    .BellStop { ... }
    .ButtonWhite { ... }
    and then use :

      button.toggle(!button.pressed);
      
      if (button.pressed) {
        button.setIconCls('BellStop');
      } else {
        button.setIconCls('ButtonWhite');
      }
  3. #3
    Disregard what I said =P. #IconName means something special for Ext.NET.
  4. #4
    Hello!

    Couldn't reproduce. I've tried the following code:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <script>
            var toggleHandler = function(button) {
                button.toggle(!button.pressed);
    
                if (button.pressed) {
                    button.setIconCls('#BellStop');
                } else {
                    button.setIconCls('#Accept');
                }
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <ext:Button runat="server" Icon="ThumbUp">
            <Listeners>
                <Click Fn="toggleHandler"></Click>
            </Listeners>
        </ext:Button>
    </body>
    </html>

Similar Threads

  1. Replies: 2
    Last Post: Nov 23, 2012, 2:45 PM
  2. [CLOSED] Avoid unselected Toggle Buttons
    By softmachine2011 in forum 2.x Premium Help
    Replies: 2
    Last Post: Nov 16, 2012, 9:33 AM
  3. changing Icon of a TreeNode
    By _xpto in forum 1.x Help
    Replies: 1
    Last Post: Oct 26, 2012, 4:10 PM
  4. Replies: 1
    Last Post: Apr 03, 2012, 10:42 PM
  5. Changing Icon on TreePanel node
    By wh0urdady in forum 1.x Help
    Replies: 1
    Last Post: Jun 14, 2010, 3:31 PM

Posting Permissions