PDA

View Full Version : Going crazy on overrides....



drunkmoose
30 Mar 2011, 7:14 AM
Hi!

I remember using event override's before, but this time, I've been banging my head on the monitor for too long.

Tell me if I'm wrong, but this should work.


Ext.override(Ext.form.FieldSet, {
beforeexpand: function() {
alert("This is madness....");

}
});

No parsing errors but no alert either. What is going on here exactly ? :-?

Thanks.

fay
30 Mar 2011, 7:33 AM
The event is called 'beforeexpand', but I think internally the (private!) method you want to override is beforeExpand (capital E). When stuck with something like that I'd recommend going straight to the source code for Ext.form.FieldSet and see what it does.

drunkmoose
30 Mar 2011, 7:34 AM
Jeesss... Sorry about that, overriding only works for methods, not events. At least when I changed "beforeexpend" to "expand" (the method) it worked!

:">

drunkmoose
30 Mar 2011, 8:04 AM
Actually, it works but the panel does not expand any more. No anim.

Here's what I did:


//Copy the original method so we can call it later
var originalExpand = Ext.form.FieldSet.prototype.expand;
//The override...
Ext.override(Ext.form.FieldSet, {
expand: function(a) {
//custom code....
originalExpand.apply(this);

}
});



:D

mschwartz
31 Mar 2011, 6:09 AM
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/function/apply

You're not passing enough arguments to apply()

drunkmoose
31 Mar 2011, 6:12 AM
Actually, I was passing TOO MUCH arguments.

Had it wrong.



originalExpand.apply(this);


Works fine in all browsers




originalExpand.apply(this, arguments);


Does not work in IE8 but fine in all other browsers.