Prototype with Raphael

33 views
Skip to first unread message

code1n

unread,
Dec 17, 2009, 7:07:49 AM12/17/09
to Prototype & script.aculo.us
hello everyone.
i'm trying to use raphael svg graphic library with prototype
there is a question wich is troubeling me - how to extend svg elements
with prototype?
For example, i use this code:

r = Raphael($("container"), 300, 300);
c = r.circle(100, 100, 50);
c.attr('fill', 'red');
c.node.toggleClassName("half_opacity")

this doesn't works because c.node.toggleClassName("half_opacity")
enteres enteres to toggleClassName(element, className) function with
first argument "half_opacity" and undefied second element. it has same
effect as i've been calling Element.toggleClassName("asd").
c.node.toString() returns [object SVGCircleElement]. SVGCircleElement
inherits SVGElement, wich has Element as "Superinterface".
I tried Object.extend(c.node, Element), but it doesn't make sence.

I liked to use Raphael in my work, using it with Prototype will brings
more facilities.
One more question - is there any svg library wich supports prototype?

heeae

unread,
Dec 20, 2009, 11:08:40 PM12/20/09
to Prototype & script.aculo.us
o ... i have some mess up after viewing the raphael doc
c.node is html element but not extended by prototype
please use $(c.node) to make it extended by prototype

heeae

unread,
Dec 20, 2009, 11:06:30 PM12/20/09
to Prototype & script.aculo.us
um... i have not used raphael.
you want to toggle Class name to $("container") ? or the sub element
created by raphael?
for first one, simply $("container").toggleClassName("...")
for the second one, you have to know how raphael works
but i think raphael will provide a way to the get html element from
c.node (e.g. c.node.elements[0])
toggleClassName can only work in htmlElement, try to find the exact
htmlelement first in order to use html related functions

heeae

On Dec 17, 8:07 pm, code1n <lomov...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages