PDA

View Full Version : Custom Component Troubles



jcarp
8 Sep 2009, 6:33 AM
I'm trying to create a custom button that doesn't include the standard extJS background - only an image.

I'm having two problems:

a) Tooltips don't seem to work (using either with tooltip attribute or QuickTips)
b) If I change the CSS class programmatically (myButton.btnCls = 'newButtonCSS'), the image isn't updated

Below is the custom component; anyone help me out?

-----


// custom component for a simple image button
Ext.ux.ImageButton = Ext.extend(Ext.Component, {

btnCls: '',

handler: function(){
},

initComponent: function(){
Ext.ux.ImageButton.superclass.initComponent.call(this);

this.addEvents( /**
* @event click
* Fires when this button is clicked
* @param {Button} this
* @param {EventObject} e The click event
*/
"click");
},

onRender: function(ct, position){
this.el = ct.createChild({
tag: 'div',
cls: this.btnCls
});
this.el.on('click', this.onClick, this);
},

onClick: function(e){
if (e) {
e.preventDefault();
}
if (e.button != 0) {
return;
}
if (!this.disabled) {
this.fireEvent("click", this, e);
if (this.handler) {
this.handler.call(this.scope || this, this, e);
}
}
}

});

24 Sep 2009, 9:11 AM
setting a reference programatticaly will not update the DOM. you need to code for that.

are you executing Ext.QuickTips.init(); ??