Ajax functions with embedded objects


#1

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


#2

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