Re: Prototype: 2 questions (elements'' attributes, dumping methods)

Ken Snyder
Tue, 17 Jul 2007 18:32:02 -0000

Alx wrote:
> hello again)
>
> 1) i just wanted to know is it possible to get element''s
attributes in
> hash or array?
> for example something like this:
> <span style="color:red;" id="myEl"
onclick="alert(1)">
> ..
> $(''myEl'').attibutes().length // == 3
>
>
I don''t see a built-in method.  If you loop through an element using
for-in or $H(element).inspect() you''ll notice a lot of browser-specific
attributes that may not mean anything to you.  So the question is, with
which attributes are you concerned? Then, just make a function that
looks for those.  But be aware that even if style is not defined in the
HTML, it is still a property of the element.  So you may need a regex
that looks at innerHTML get what you need.

> 2) is there any analogues of php functions var_dump() and print_r()
> for Objects/Hashes and Arrays?
>
inspect() is probably what you need.

- Ken Snyder

--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---