PDA

View Full Version : Extending Ext.Element and base



vtjiles
11 Sep 2008, 8:22 PM
After reading the tutorials on extending objects in Ext I'm still confused. Could someone explain or provide code on how to create a function which extends both Ext and Ext.Element?

I'd like to be able to call Ext.myfunction and have it work with the get function like Ext.get("element").myfunction.

Thanks

evant
11 Sep 2008, 8:24 PM
Ext.Element.prototype.myFunc = function()
{
console.log(this.dom.innerHTML);
};

Ext.onReady(function()
{
Ext.get('foo').myFunc();
}
);

vtjiles
11 Sep 2008, 8:31 PM
Thanks for the quick reply, but this doesn't seem that it'd support Ext.myFunc() as well.

The code I've tried was:

Ext.myFunc = function() {
//something
}

Ext.Element.prototype.myFunc = function() {
//sets the configuration object and calls Ext.myFunc
}

The issue is the function makes an Ajax call and when making multiple calls at once the config references are lost.

evant
11 Sep 2008, 8:37 PM
Ext.myFunc = function()
{
alert('foo');
};
Ext.Element.prototype.myFunc = Ext.myFunc;