-
19 Jul 2012 9:47 PM #1
Unanswered: How to change CSS style of an Image Button?
Unanswered: How to change CSS style of an Image Button?
Hi,
I have tried something like this. It is not working. Any idea?
thx,Code:{ xtype: 'button', style: { height: "75px", "background-image": "url(image/all.png) !important" }, handler: function(button, event) { Ext.StoreMgr.get('ViewMyPromo').load(); Ext.getCmp('tpsViewport').setContentsContainerCardActive(0); //this.applyStyles({ // height: "75px", // "background-image": "url(image/all-active.png) !important" //}); this.setStyle('backgroundColor','#dddddd'); }, width: 80, disabled: true }
Zol
-
19 Jul 2012 10:19 PM #2Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 77
- Answers
- 124
HI!
you may try to add a class on your button (td), sample is below:-
Working example:- http://jsfiddle.net/molecule/TbTxG/2/Code:.without-hover td { background-image: none; } var button = new Ext.Button({ text: 'without hover', cls: "without-hover", renderTo: Ext.getBody() // ... });sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
19 Jul 2012 11:15 PM #3
thank you
What I really looking for is to change the background image later - once user clicked on it.
this.setStyle() and this.applyStyles() on type: button is undefined.
-
19 Jul 2012 11:19 PM #4Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 77
- Answers
- 124
Hi!
if you want to change css when user clicks on it, you may try to use pressedCls.
Sample:-
.sampleClass{
background: XXXXXX !important;
}
http://docs.sencha.com/ext-js/4-1/#!...cfg-pressedClsCode:{ xtype:"button", html: '*******', pressedCls:'sampleClass', ...... }sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
20 Jul 2012 12:08 AM #5
thanks. I have tried with presentedCls and overCls to see is it catching or not:
xtype: 'button',
style: {
height: "75px",
"background-image": "url(image/all.png) !important"
},
overCls: 'viewButtonActiveClass',
and my index.html has:
<style>
.viewButtonActiveClass {
background-image: url(image/all-active.png) !important;
}
</style>
what I am doing wrong?
thx
-
20 Jul 2012 12:12 AM #6Sencha - Community Support Team
- Join Date
- May 2012
- Location
- Istanbul
- Posts
- 1,331
- Vote Rating
- 77
- Answers
- 124
try:-
.viewButtonActiveClass td {
background-image: url(image/all-active.png) !important;
}sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
20 Jul 2012 12:51 AM #7
added one more class:
.viewButtonClass td {
height: "75px";
"background-image": url(image/all.png) !important;
}
.viewButtonActiveClass td {
height: "75px";
"background-image": url(image/all-active.png) !important;
}
this would replace the system on item def.
xtype: 'button',
cls: 'viewButtonClass',
overCls: 'viewButtonActiveClass',
right now the image is not shown, and also no hover-over effect as the button had.
"style" is adding as an extra, can I only manipulate the a style property instead of changing the current class?
thx
-
23 Jul 2012 3:42 AM #8
Hi try this:
css:Code:{ xtype: 'button', iconCls: 'pagenext' }
and finally:Code:.pagenext { background-image: url(images/page-next.gif) !important; } .pageprev { background-image: url(images/page-prev.gif) !important; }
This works for me!Code:button.setIconCls( 'pageprev' );
-
23 Jul 2012 7:41 AM #9
thanks Guys!
unfortunately the setIconCls is not good for my case, as my images 75 x 75 pixels. The maximum icon size you can select is 32x32 pixels if set scale to large. I am not able to define a new scale, as extjs 4 blocking it with an exception.
it is possible to that really impossible to make an image button with ext?
thx,
Zol
-
24 Jul 2012 2:27 AM #10
this is what finally worked for me as a full image "button":
{
xtype: 'image',
itemId: 'viewButton',
src: 'image/all.png',
height: 75,
width: 75,
alt: 'VIEW',
disabled: true,
listeners: {
render: function(c) {
c.getEl().on('click', function(e) { this.setSrc('imgname0'); /* click logic */ }, c);
c.getEl().on('mouseover', function(e) { this.setSrc('imgname1'); }, c);
c.getEl().on('mouseout', function(e) { this.setSrc('imgname2'); }, c);
}
}
}


Reply With Quote