-
14 Sep 2007 3:18 AM #1
Ext.Button iconCls gotcha
Ext.Button iconCls gotcha
Hello all,
I was puzzled by the iconCls config option for Buttons. The following fails to work as I would expect:
JS:
CSS:Code:var b = new Ext.Button('test-button',{ iconCls:'an-icon', text:'click on me!' })
In fact, you *must* specify the class on button:Code:.an-icon { background-image: url(../icons/someicon.png); background-repeat: no-repeat; }
Hope that saves someone some time,Code:button.an-icon { background-image: url(../icons/someicon.png); background-repeat: no-repeat; }
Matt.
-
14 Sep 2007 4:02 AM #2
This is not a bug, it's a feature of CSS. selector specificity.
The standard: http://www.w3.org/TR/CSS21/cascade.html
An article: http://cmsproducer.com/css-specificity-inline-important
-
14 Sep 2007 6:51 AM #3
Thanks Animal - that explains a lot.
Matt.
-
14 Dec 2007 6:49 AM #4
Thanks Matt, this got me!
-Lobos
-
9 Jan 2008 2:12 PM #5
Doesn't work for 'action'
Doesn't work for 'action'
I have a related issue. When using iconCls on an action, the button specifier must also be used...but then you cannot have an action in both a button and a menu item unless you want to duplicate the class. Once with "button" at the beginning, once without. I cannot figure out why this works in the ext example "actions" and not in my site. Anyone else run into this problem?
CSS:
JS:Code:.sprite-forward { background: url(Images/App/sprites.gif) no-repeat top left; background-position: 0 -76px }
When the action is used for a toolbar action, no icon shows upCode:new Ext.Action({ iconCls: "sprite-forward", text:"View Results", id: "view" })
When the same action on the same page is used in a context menu as a menu item, the icon shows up nicely.Last edited by Ebezester; 9 Jan 2008 at 2:30 PM. Reason: Added more details
-
30 Jan 2008 5:02 AM #6
iconCls on Action
iconCls on Action
Ebezester, I had the problem when icon was not showing for Ext.Action. When I added the "button." it works perfectly.
Have you tried using FireBug in FF? If you inspect the element and look to the right where assigned CSS properties are and navigate to the class you are using for icon - "button.sprite-forward" in your case. When you hover over the path FireBug should be able to load the icon and show it. If it doesn't show the path might be wrong.Code:button.icon_new { background-image: url(resources/ext/resources/images/default/dd/drop-add.gif); }
Hope this helps.
-
31 Jan 2008 9:54 AM #7
I also had the same problem
I also had the same problem
To share the same class use the css !important rule. This worked for me
Code:.icon_new { background-image: url(resources/ext/resources/images/default/dd/drop-add.gif) !important; }
-
12 Aug 2008 11:17 AM #8
Me too
Me too
I also have the same behaviour. Adding the button class does nothing. Interestingly, applying the 'iconCls' makes space for the icon, but the image doesnt appear. If I add the icon directly to the action button using 'icon' its fine. The CSS is valid and functioning; just not when being applied via iconCls to a button/action within a tab panel.
Im using build 2.2.
Any ideas?
-
12 Aug 2008 6:36 PM #9
i'm using Ext.Buttons from 2.2 with the iconCls config, and my icons are appearing.
are you absolutely sure your css image paths are correct?
(a long shot in the dark, but when updating, did you also update your images and css?)
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
13 Aug 2008 6:07 AM #10
I had a related question about icons. I can see the icon within the button, no problem. But what do I do to get the icon to replace the button (so that the button becomes an imagebutton)?
Thanks a lot!



Reply With Quote

