Hi Hippyjim Starbrook,
this is not the way you should do. It's better to use a wrapper to t
(he native function. First because you did not modify the standard
behaviour of prototype, and also because you still have the capability
to call the original function.
Have a look to the wrap() function at
http://api.prototypejs.org/language/function.html#wrap-instance_method
In you case, you could do something like that:
Form.Element.Methods.disable=Form.Element.Methods.disable.wrap(
function(OriginalCall,ExtraParameters){
//do what you want here,
//this refer to a Form.Element.Methods object.
...
//call original method and return it's value if needed.
return OriginalCall(this);
}
);
The OriginalCall is the original prototype function you overide. You
can (or of course not) call it.
hope that help.
--
david
On 25 nov, 22:30, Hippyjim Starbrook <[email protected]>
wrote:
> Hi All
>
> I'm attempting to extend the Form.Element.disable() method, so that it
> adds a "disabled" class to any element is disables.
>
> I'm attempting to replace the existing prototype function with one of
> my own, using the following code in a javascript file loaded after
> prototype.js:
>
> Form.Element.Methods.disable = function(element) {
> element = $(element);
> element.blur();
> element.disabled = true;
> element.addClassName("disabled");
> return element;
>
> }
>
> But it doesn't seem to replace the original prototype method.
>
> Am I missing something?
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.