Forum: Ruby on Rails Ajax functions with embedded objects

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fa922fb19b46fbcf8bb3c19dba6a3bcc?d=identicon&s=25 Henrique Testa (hgtesta)
on 2006-02-28 14:33
Hi,
In my project, there is an rhtml page with an embedded SVG file. In my
javascript functions, I can find an object by id inside the SVG file
with the following:

ObjectInSVG =
top.document.embeds[0].getSVGDocument().getElementById("rect");

Now, I want to use Ajax methods, like link_to_remote, in the rhtml page
to manipulate the SVG objects. The problem is that link_to_remote method
uses the id to identify the object... but the object is embedded! Is
there any way to pass the object reference to the link_to_remote instead
of just the id?

Thanks for the help!

Henrique
531eb73f8fbf05a197721d02b4e6aadb?d=identicon&s=25 Bogdan Ionescu (Guest)
on 2006-02-28 16:14
(Received via mailing list)
I am assuming that you would like to do something like
link_to_remote("click",:update=>"svg_id"...)
If that is the case you could do
link_to_remote("click",:update=>"",:complete=>"init_svg('svg_id',
request.responseText)"...)

function init_svg(svg_id, content){
do_whatever(top.document.embeds[0].getSVGDocument().getElemen
>
> tById(svg_id), content)
>
}

You should check in prototype.js if $() accepts objects and not just the
id
string (I suspect that it does)

bogdan
This topic is locked and can not be replied to.