Hi marx,
I try to do the following:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/...">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg">
<head>
<script src="prototype.js" type="text/javascript"></script>
<script src="scriptaculous.js" type="text/javascript"></script>
<style type="text/css">
</style>
</head>
<body>
<div id="test" class="toto2"></div>
<svg:svg width="600px" height="400px" style="display:block;">
<svg:polygon id="triangle" points="50,50 50,300 300,300" style="
fill:blue; stroke:black;" class="toto" />
</svg:svg>
<script type="text/javascript">
alert('HTML !!!');
var _t=$('test');
alert(_t.className);
_t.addClassName('test2');
alert(_t.className);
alert('SVG !!!');
var _t=$('triangle');
alert(_t.className);
_t.addClassName('test2');
alert(_t.className);
</script>
</body>
</html>
and the addClassName method is working fine as you could see if you
test my poor exemple.
Try looking if the $('room'+num) return an element, and if it return
an element, look at its method.
If prototype method does not exist, try to extend your selected object
with prototype method.
--
david
On 28 fév, 22:02, marx <[email protected]> wrote:
> Hi all,
> I'm currently writing an application that displays a floor plan using
> SVG, embedded within an HTML div.
> I'm writing the javascript code to make the floor plan interactive,
> allowing you to select rooms etc. However I've hit a snag.
> I was writing a simple function to let me change a room's colour when
> it's clicked. I set up the CSS class I wanted to add to the element
> that was clicked, and created the onclick function, here's how it
> looked:
>
> function select_room(num) {
>
> index = selected.indexOf(num); // find the index of the room number
> in the array
> if (index < 0) { // If the room number isn't in the selected array
>
> selected.push(num); // add the number to the array
> $('room'+num).addClassName("selected"); // Use addClassName to add
> the "selected" class to the room
>
> } else { // If the room's already selected
>
> selected[index] = null; // remove the number from the array
> selected = selected.compact(); // Remove the null index from the
> array
> $('room'+num).removeClassName("selected"); // Use removeClassName
> to remove the "selected" class.
>
> }
>
> $('selected').value = selected;
>
> }
>
> However, when the function ran, I got the error "$
> ('room'+num).addClassName is not a function". After some head-
> scratching and a bit of debugging, I realised that $('room'+num) is
> returning an SVG element instead of an HTML element (as described in
> the API docs). Does this mean that the associated methods aren't
> available? Is there any workaround to make (at least the applicable
> ones) available?
> Many thanks,
> Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---