First, you need to add to Form.Element.Methods (this will affect
"input", "select" and "textarea" elements). Then, you just need to
call Element.addMethods() (this will actually extend elements):
Object.extend(Form.Element.Methods, {
...
});
Element.addMethods();
Best,
kangax
Then, you just call Element.addMethods();
On Apr 9, 7:17 am, Dan <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> first, i'm new to Prototype. I want to extend Prototypes Form.Element
> class with a few function like this:
>
> Object.extend(Form.Element,{
> pointize : function(element) {
> if ($(element).present()) {
> return element.getValue().sub(',','.');
> }
> return element.getValue();
> },
> toFloat: function(element) {
> if ($(element).present()) {
> return parseFloat(element.pointize());
> }
> return 0.0;
> },
> toInt: function(element) {
> if ($(element).present()) {
> return parseInt(element.pointize());
> }
> return 0;
> }
> });
>
> But if i want to call one of these functions on an input element like $
> (myInputElementId).toFloat() i always get an error that toFloat is not
> a function... what do i wrong?
>
> Thanx in advance!
> Bye Dan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---