On Apr 19, 5:49 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> > Because Form isn't a function, it's a plain object with some
> > properties. Look at line 2548:
>
> > var Form = {
> > ...
> > }
>
> I had seen that, but *Element* is declared just like *Form* and
> Element('blabla').hide()
> works.
It does? I get "Element is not a function", just like I get with
Form.
>
> This looks more like a bug, *all* of these extensions to the DOM are
> usually
> available as Singletons,
Maybe that's causing confusion. They aren't "extensions", they are
objects with properties. Some (most?) of those properties are
references to function objects. For Firefox et al, the base DOM
objects are extended with the same function objects. For IE and
similar, they aren't.
Don't think of javascript as a classic object oriented language - it
isn't, it's *object based*.
> and besideshttp://www.prototypejs.org/api/form/reset
> gives an example using Form as a singleton.
The example is:
Form.reset('contact')
which is using the reset property of the Form object which expects
either an ID or a form object as the parameter. It is not attempting
to "call" the Form object like Form() which will produce a runtime
error.
Try:
alert( typeof Form ) // shows object
alert( typeof Form.reset ) // shows function
alert( typeof Element ) // shows object
alert( typeof Element.toggle ) // shows function
It would probably have been better if Prototype hadn't named it's own
objects the same as other DOM and javascript objects. e.g. calling the
library 'Prototype.js' causes plenty of confusion with those trying to
learn about the javascript prototype property and object which are
totally different to the Prototype.js library and the Prototype object
declared within it.
>
> > but if all the function does is enable the form, why not:
>
> > onclick="$(this.form).enable();"
>
> It is not all it does, I was just being succint.
Fine. :-)
--
Rob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---